Questions tagged [lua]

Question about the Lua binding in Neovim

Filter by
Sorted by
Tagged with
0 votes
2 answers
124 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
49 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
1k 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
279 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
47 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
3k 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
292 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
3 answers
488 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
133 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
180 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
5k 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
3 votes
2 answers
616 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
252 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
36 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
72 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
  • 91
0 votes
0 answers
603 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
114 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
92 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
438 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
  • 209
0 votes
0 answers
275 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
529 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
  • 91
4 votes
1 answer
1k 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
4 votes
1 answer
213 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
908 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
2k 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
542 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,106
0 votes
1 answer
498 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
1 answer
123 views

How to make the 81st column stand out in Lua?

Like this for Vim, I'm trying to convert (with no success): matchadd('ColorColumn', '\%81v\s*\zs\S', 100) from vimscript to a Lua autocmd: autocmd({'BufRead'}, { pattern = "*", ...
Joannes's user avatar
  • 237
0 votes
1 answer
1k views

Is there a popular config for Neovim? [closed]

I found a lot of repositories in Github about init.vim like amix vimrc but I couldn't find anything about init.lua. Do you know some repository? I think many of people still using Vim.
mohamadi_arch's user avatar
1 vote
2 answers
265 views

System wide sysinit.vim but in lua

sysinit.vim works like a charm, but I want to fully transit into lua. How file should be called? sysinit.lua doesn't work.
Kuń's user avatar
  • 11
0 votes
1 answer
2k views

How to include/configure lua_ls on lspconfig?

I am trying to include lua_ls on my lspconfig but I am getting this error [lspconfig] Cannot access configuration for lua_ls. Ensure this server is listed in `server_configurations.md` or added as a ...
zer09's user avatar
  • 199
7 votes
2 answers
13k views

How can I change the root of my nvim-tree?

I have checked this screenshot (list of nvim-tree commands): But there seems to be no command to change the root of my tree. Also I am hoping to setup a convenient startup location but could not find ...
samuelnihoul's user avatar
0 votes
2 answers
6k views

How can I enable all NvChad features?

I am struggling to enable the features advertised on https://nvchad.netlify.app/features. Upon installation, we only get basic features such as tabs and command bar, as per my experience and what I ...
samuelnihoul's user avatar
2 votes
1 answer
6k views

How can I setup a nerd font in init.lua?

I am in Windows 11. I have downloaded and installed all the fonts 'CascadiaCode'. I have tried to add some thing like vim.g.guifont="CascadiaCode" to my init.lua but can't figure it out.
samuelnihoul's user avatar
5 votes
2 answers
5k views

How can I change the default terminal in Neovim (lua)?

I have tried adding this line to the init.lua but it doesn't work and I don't understand the syntax: local g:terminal_emulator="powershell" I get an error upon running the source command: ...
samuelnihoul's user avatar
1 vote
0 answers
418 views

How to create a (lua) function to run a particular command in the shell on the currently open file, within neovim

If I'm working on a file I might want to run a particular command which uses the file within the shell. Example - running black (python formatter) on an open file. Ideally I'd like to be able to enter ...
baxx's user avatar
  • 1,025
0 votes
1 answer
3k views

Sumneko lua-language-server failed to load

My OS is openbsd 7.2 with neovim v0.7.2. I am using the repo at https://github.com/amy-juan-li/nvim-lua.git to configure Neovim. There is a problem with the neosolarized.rc.lua file. Can anyone see ...
shadrock's user avatar
0 votes
2 answers
3k views

Configuring VimTeX in NvChad config

I've been trying to configure vim-tex working on the NvChad configs. I got the :VimtexCompile working and giving me output pdf. But the usual <leader>ll is giving me these errors. Also in vim {{ ...
codehumor's user avatar
  • 101
1 vote
0 answers
228 views

Is it possible to resize a floating window?

As title. Say I just created a floating window and some lines of it are too long to be displayed properly(to me), then in this case I would prefer to resize that window to make it larger instead of ...
NeoZoom.lua's user avatar
  • 1,462
1 vote
2 answers
150 views

Detect Editing of Directory

How do you detect if a directory is opened(with :edit) in Vimscript? I am lazy loading a file explorer and need it to load it before I open a directory. One approach I tried using an autocommand that ...
unrealapex's user avatar
1 vote
2 answers
1k views

How to add <bits/stdc++.h> header file in Clangd installed through Mason (Neovim lua)?

I want to add/expand the Clangd Language server, which I installed through Mason within Neovim, with the standard libraries that come with MinGW (I run windows 11). I'm trying to do CP, and for that I ...
cringeyburger's user avatar
0 votes
0 answers
130 views

how to configure conjure aniseed parinfer in lua for neovim clojure development?

I'm using neovim for clojure development. I would like to setup below plugins. Olical/aniseed Olical/conjure gpanders/nvim-parinfer PaterJason/cmp-conjure I don't know how to setup rudimentary ...
Rajkumar Natarajan's user avatar
0 votes
0 answers
829 views

Create a temporary, readonly buffer for test output in Neovim

I want to create a Neovim plugin that automatically runs a test suite whenever a file is saved. Here's an overview: If I save a Rust file, run cargo test If there's not a buffer opened for the test ...
Nick's user avatar
  • 101
0 votes
1 answer
1k views

Unable to install luasnip

After installing luasnip I encountered this error: Even though cmp is already installed Plugins.lua use({ "onsails/lspkind-nvim", event = "VimEnter" }) use({ "L3MON4D3/...
Rohith Nambiar's user avatar
1 vote
1 answer
370 views

How to check if the lua function is available in vim script?

On nvim, we can use 'v:lua' prefix to call a lua function in vim script. But can we check if the lua function is available, like exists('*funcname')?
Rick Howe's user avatar
  • 353
1 vote
1 answer
2k views

How to insert text from lua function at cursor position (insert mode)

I realize there is a similar question here but using vimscript. I have created a function that returns a uuid in lua. But I would like to assign this to a keymap and insert the text at the cursor ...
Boyd's user avatar
  • 209
0 votes
1 answer
36 views

The pattern of `DirChangePre` is strange where it jumps between `global` and `tabpage`?

As title. I'm trying to fix my plugin with a problem related to the pattern of autocmd. I know that the event DirChangedPre brings a pattern with it when it happens. To reproduce the strange thing I ...
NeoZoom.lua's user avatar
  • 1,462
2 votes
1 answer
638 views

Minimap config in lua

Sorry if the question looks dumb, is it possible to set the config file of minimap in lua ? I test the following, but the plugin is not found (the package command works wheel eg. Minimap or ...
Hadock's user avatar
  • 143
-1 votes
1 answer
81 views

What's the corresponding command of `CTRL-Y` and `CTRL-E`?

As title. I know that I can just press CTRL-Y/E to scroll, but now I need to use a script to execute them. What are the commands?
NeoZoom.lua's user avatar
  • 1,462