Questions tagged [lua]

Question about the Lua binding in Neovim

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

How to detach/disable a buffer-update callback in nvim

In vim, we can implement a vim script, which monitors text changes in details, with listener_add(), listener_remove(), listener_flush(). In nvim, nvim_buf_attach() is available to attach a callback. ...
Rick Howe's user avatar
  • 313
2 votes
1 answer
77 views

Avoiding name conflicts in ~/.config/nvim/lua/

I've installed telescope.nvim plugin for NeoVim. Now, I would like to put some configuration code related to this plugin in this file: ~/.config/nvim/lua/telescope.lua In my init.lua file, I've ...
Flimm's user avatar
  • 2,182
0 votes
2 answers
69 views

How to exclude a specific buffer from the BufEnter autocmd group?

I want to load a plugin when I enter a buffer, so I set this event to BufEnter. But when I start neovim, the plugin loads at the dashboard buffer. I want to exclude that buffer. How can I do it? ...
Nias26's user avatar
  • 11
0 votes
1 answer
173 views

Configuring vimwiki in neovim

I am struggling with the basic configuration for vimwiki in neovim. I cannot get it to use my configuration. For import I am using lazy.nvim. This is the concerning lazy-section: {"vimwiki/...
hmaier's user avatar
  • 113
0 votes
0 answers
38 views

goto definition

I'd like to have a shortcut ('gD', say) to go to the definition using vim.lsp.buf.definition; however, in a new tab (if this is not open yet), or in the tab already open.
Alois Pichler's user avatar
0 votes
0 answers
74 views

packer error "module 'packer.luarocks' not found:"

I am trying to install packer.nvim to my NvChad configuration. I installed packer using git clone https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start\...
ori raisfeld's user avatar
1 vote
1 answer
107 views

Why are non-existent vim.fn functions defined in Neovim's Lua API?

From within Neovim, I can execute the command :lua print(vim.fn.non_existent_function), and would get something like function: 0x01052bc2a8 as the printed output. But of course, if I were to actually ...
Jethro Cao's user avatar
2 votes
1 answer
76 views

Neovim: Converting Vimscript Terminal Functions to Lua

Author: @mizlan Source: https://github.com/mizlan/vim-and-cp/blob/master/cp.vim#L16 This code adds charm to neovim integrated terminal. For cpp programs, I have these: F9 compile, F10 run, F12 ...
Mega Bang's user avatar
  • 199
0 votes
1 answer
154 views

I need help updating config code from vimscript to lua

About three years ago, I had gathered chunks of code from the net and made my init.vim config file. Now, with Lua released, I am unable to convert it. And it's down to you folks whether you can help ...
Mega Bang's user avatar
  • 199
0 votes
1 answer
186 views

Error when configuring lspconfig with mason

I'm trying to set up autocompletion, fixing, etc. for lua files in Neovim. I started by trying to follow the instructions from this video: https://www.youtube.com/watch?v=lpQMeFph1RE&t=188s ...
quant's user avatar
  • 101
0 votes
1 answer
74 views

In Lua, how can I check if a buffer exists on disk?

I use Neotree on Neovim, and have mapped a key to open the file browser which is supposed to: open the file browser pointing to the current file if there is no filename, open the file browser at the ...
artfulrobot's user avatar
0 votes
0 answers
22 views

How to change spelllang alias in vim-airline (option `vim.g.airline_detect_spelllang = 1`)?

I have enabled the vim.g.airline_detect_spell = 1 and vim.g.airline_detect_spelllang = 1 options (config is written in Lua and can be found here). The vim.g.airline_detect_spelllang = 1 makes the vim-...
Vladyslav Rehan's user avatar
0 votes
0 answers
17 views

switch to terminal opened from autocomand

I am trying to create autocommand to run current python file in a terminal, when it is saved. It is working with the following autocommand: vim.api.nvim_create_autocmd("BufWritePost", { ...
user48990's user avatar
2 votes
1 answer
166 views

How do you pass options to a lua plugin?

In many Neovim plugins these days, configuration is done in a new way, and the readme just says to "pass option_name = someval to enable some behaviour". For example, archibate/nvim-gpt, ...
TamaMcGlinn's user avatar
1 vote
1 answer
484 views

Neovim/Lua: How to use vim.keymap.set with vim.v.count

I'm trying to add a count to one of my keymap bindings. vim.keymap.set("n", "<leader>o", vim.v.count .. 'o<Esc>') does not work as expected. My intention for this ...
agshe's user avatar
  • 23
0 votes
0 answers
40 views

How to detect whether current cursor position is code-block in markdown file from lua function?

Target: Trying to write lua function that will return true if current cursor position in code-block in markdown, false if not. Current Status: I have following code, that (based on tree-sitter) ...
Garid's user avatar
  • 103
2 votes
1 answer
76 views

Neovim paste without overwriting register w/ Lua

So I know with vimscript you could make paste not overwrite your register with this: vnoremap p pgvy And I've tried a few ways to get this to with with Lua such as: vim.api.nvim_set_keymap('n', 'p', '...
Zach B.'s user avatar
  • 123
1 vote
1 answer
117 views

Is there an autocmd event that triggers when a command becomes available?

I'm using nvim-lsp and pyright. That latter provides a command PyrightSetPythonPath to reset the path to the python interpreter. Since I can see no other way to perform the same task, I'd like to call ...
Futarimiti's user avatar
1 vote
1 answer
471 views

How to install nvim-html-css neovim plugin in NvChad

Neovim plugin: nvim-html-css I don't know lua but I need this plugin installed for bootstrap classes. I have Neovim NvChad lazy.nvim setup. Copy pasting didn't worked so I tried to cut out maybe ...
over-heaven's user avatar
1 vote
1 answer
105 views

How to fix RGB / RGBA colors not being shown as colors in neovim nvChad lazy.nvim colorizer plugin?

I can see color on those: #000000 red But not on those: rgb(0,45,65); rgba(2,45,23,1); Here is C:\Users\user\AppData\Local\nvim\lua\plugins\init.lua file colorizer code that comes preinstalled with ...
over-heaven's user avatar
0 votes
1 answer
184 views

Neovim: Telescope fails to find `tbl_isarray`

I run Neovim v0.9.1 using Lua 5.1 (not LuaJIT) and telescope. As soon as I invoke telescope.builtin.git_files, Neovim shows the following error: E5108: Error executing lua: ...ugins/telescope.nvim/lua/...
PEAR's user avatar
  • 101
0 votes
2 answers
72 views

Argument of extend() must be a List or Dictionary, using List as a String errors

I have next init.lua in ~/.config/nvim vim.cmd [[packadd packer.nvim]] require('packer').startup(function(use) -- Packer can manage itself use 'wbthomason/packer.nvim' use 'vim-...
Vladyslav Rehan's user avatar
0 votes
0 answers
31 views

How to use Neovim `sockconnect`?

I want to write a plugin that start 2 child processes. let's say the main nvim process is P, parent. and two child processes are A and B. In process A, I will do some calculation and write data to ...
linrongbin's user avatar
1 vote
1 answer
342 views

How to load the global "vim" object so lua-language-server stops complaining

Here is how I start the server: -- LSP vim.lsp.start({ name = 'lua-language-server', cmd = { 'lua-language-server' }, root_dir = vim.fs.dirname(vim.fs.find({'.git', '.vim', 'nvim'}, { upward = ...
Ari Sweedler's user avatar
0 votes
1 answer
115 views

How to run a callback when an nvim plugin is loaded. Can I tie this back to running a callback when a plugin is required/imported?

I can see in vim how we can: Call function only when the plugin is loaded But I want to: Call function only when the plugin is required
Ari Sweedler's user avatar
0 votes
1 answer
31 views

Lua insert mode mappings are pasting the rhs in buffer instead of executing them

In my init.lua, I've got some keys bound to some actions in insert mode. e.g.: vim.keymap.set('i', '<C-j>', '<Plug>(easymotion-bd-w)') But when I press Ctrl-ew, instead of highlighting ...
technicguy1's user avatar
1 vote
1 answer
1k views

Get ruff / ruff_lsp to work with neovim

I tried kickstart.nvimi to get to work with the ruff-lsp. It did not work, therefore I built a minimal example with only the default configuration from the documentation. Here is the problem: When I ...
Dronakuul's user avatar
0 votes
1 answer
129 views

Use LspConfig root_dir in Neogit cwd

I'm trying to setup Neogit to open in my workspace directory instead of cwd. The problem is that I use multi root workspaces, so I usually set my cwd to be workspace1/... My initial try was to use ...
Gustaw's user avatar
  • 1
1 vote
2 answers
202 views

How can I create command abbreviations (`ca`) with the lua api?

In my init.vim, I have the following: ca WQ wq What would be the equivalent in my init.lua?
David Goldstein's user avatar
1 vote
1 answer
105 views

How to evaluate Lua in substitution field instead of vim script?

As simple example, take this: :'<,'>s/\vs([A|B])\.size\(\)/\={"A":"a","B":"b"}[submatch(1)]/g This substitution will replace sA.size() with a and sB.size(...
Vladyslav Rehan's user avatar
0 votes
1 answer
102 views

Can't apply config changes to all windows in neovim without closing the buffer at least

I am trying to update the config and see the changes take place without exiting neovim. I have structured my neovim config files like this ~/.config/nvim ├── init.lua └── lua └── [username] ...
me.nkr's user avatar
  • 41
2 votes
1 answer
3k views

Neovim lua module not found even though it exist

I have structured my neovim config files like this ~/.config/nvim ├── init.lua └── lua └── [username] ├── core │   └── options.lua ├── init.lua └── plugins These ...
me.nkr's user avatar
  • 41
2 votes
2 answers
179 views

Alt > or Alt < mappings do not work

I am trying to configure the key mappings for the barbar plugin commands, specifically the BufferMovePrevious and BufferMoveNext actions. The desired key combinations are Alt < and Alt >. ...
Jastcher's user avatar
1 vote
1 answer
138 views

Neovim append method does not works on matchpairs

I want to append <:> to vim.opt.matchpairs, which AFAIK is a string type. Neovim lua doc says: vim.opt:append() Option:append(value) ...
manungsa's user avatar
0 votes
0 answers
25 views

How to check if a function is deprecated using NeoVim Lua api

I'm currently working on neovim plugins that use vim functions through the Lua API. However, I'm not sure how to determine if a particular Vim API function is deprecated or not using the Lua API. For ...
Danielo515's user avatar
0 votes
0 answers
57 views

How to remove non printable chars in lua?

I am using astronvim. Installed copilot and set hotkey ctrl+l. Here is the code itself, lua on top, plugin below. mappings.lua file return { n = { ["b"] = { "<Plug>Sneak_S&...
serii 's user avatar
  • 57
0 votes
0 answers
432 views

error "attempt to index global 'keymaps' (a nil value)"

I am on Mac with nvim v0.9.0. I have the following „init.lua“ config loaded: vim.g.mapleader = '<Space>' local keymap = vim.keymap keymap.set("i","jk","<ESC>")...
dragontec12's user avatar
0 votes
1 answer
86 views

Specifying filetype in ModeChanged event autocmd

I'm using stylua as the code formatter for lua files. I do not usually get used to its formatting style but sometimes I do need a little help with it, so I decided to make it the formatprg during the ...
Futarimiti's user avatar
1 vote
1 answer
65 views

Error only when I'm NOT in ~/.config/nvim directory

I get this error when I open nvim in any directory other than ~/.config/nvim Error detected while processing /home/evirac/.config/nvim/init.lua: E5113: Error while calling lua chunk: /home/evirac/....
evirac's user avatar
  • 13
0 votes
0 answers
23 views

triple quotation marks

How does noremap <S-CR> <Esc>:w<CR> :execute 'SlimeSend1 include("'.expand('%:p').'")'<CR> translate to lua? Here, triple quotation marks seem to be necessary.
Alois Pichler's user avatar
0 votes
2 answers
253 views

filetype specific autocommand vs after/ftplugin in lua configuration?

Is there any reason advantage (esp using lua) to put filetype specific settings in an autocmd vs putting in after/ftplugin?
Boyd's user avatar
  • 199
0 votes
0 answers
188 views

Convert execute normal command into Lua

This handy dandy function inserts the current date and time on the current line after the cursor: function! InsertDate() execute "normal \"=strftime('%FT%T%z')\<CR>p" ...
Big McLargeHuge's user avatar
0 votes
1 answer
367 views

How can I convert Vim keymap to lua?

Hi I am using AstroNvim. Copilot help give me the following instruction about desired keybindings: imap <silent><script><expr> <C-J> copilot#Accept("\<CR>") let ...
serii 's user avatar
  • 57
4 votes
0 answers
975 views

How to disable semantic highlighting for certain filetypes only?

Using Neovim's native LSP interface, I noticed that semantic highlighting provided by LSP makes things worse for certain languages, so I want to disable it based on filetype. I know about possibility ...
Thunderbeef's user avatar
3 votes
1 answer
138 views

Trouble in overriding `indentexpr` in neovim

Say I do not quite like the shipped Lua indentexpr (GetLuaIndent(), defined in $VIMRUNTIME/indent/lua.vim). With vim, I can disable or change it using this minimal configuration: ~ % cat .vimrc ...
Futarimiti's user avatar
2 votes
2 answers
609 views

Applying commands to buffer from Neovim command line with complex plugin managers

I come from the following problem: I'm using Neovim (0.8.3) with AstroNvim as plugin/everything-manager. I've successfully set up multiple LSP servers from within that, which use the right servers, ...
Marcus Müller's user avatar
0 votes
1 answer
948 views

LazyVim: require('which-key') inside custom configuration files gives error

I use Neovim with LazyVim configuration setup. I want to set the mappings in which-key. So I put the following code inside ~/.config/nvim/lua/config/which-key.lua: local wk = require("which-key&...
Mert Nuhoglu's user avatar
0 votes
0 answers
474 views

I get several deprecation warnings printed, how to disable them?

I see this when I open first file in nvim. I have not much to do with these (those are plugins that I didn't write). How can I disable them being printed to console? sumneko_lua is deprecated, use ...
eyal karni's user avatar
  • 1,058
0 votes
1 answer
332 views

Make colorscheme change when background change

I have a shortcut to set the background light, dark, or transparent. I want to use a different color scheme for when it is dark or light. How would I go about implementing it? I don't know programming ...
enrico223's user avatar
0 votes
0 answers
43 views

Is there a lua api for mapcheck or workaround?

I have used a vimscript function for many years that toggles mapping the " key to french quotes including the non breaking space. I managed to convert this to lua and its working! My only issue ...
Boyd's user avatar
  • 199