Questions tagged [lua]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
23 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 ...
0 votes
2 answers
41 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 {{ ...
1 vote
0 answers
21 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 ...
  • 1,095
1 vote
2 answers
35 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 ...
1 vote
1 answer
58 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 ...
0 votes
0 answers
20 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 ...
0 votes
0 answers
38 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 ...
  • 101
0 votes
1 answer
39 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/...
1 vote
1 answer
34 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')?
  • 303
0 votes
1 answer
133 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 ...
  • 199
0 votes
1 answer
28 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 ...
  • 1,095
0 votes
1 answer
96 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 ...
  • 111
-1 votes
1 answer
24 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?
  • 1,095
0 votes
1 answer
162 views

How to know that neovim is started by zsh command "git commit" from my terminal emulator?

As title. I'm building a plugin and this is the last step. I've configured my .zshrc so that git will use neovim as its texteditor program to enter commit messages in interactive mode. The on-going ...
  • 1,095
-1 votes
2 answers
28 views

How to apply a command to all tabs?

As title. I want to call a command to all existing tabs to close all windows of specific filetype. How to do so efficiently?
  • 1,095
0 votes
1 answer
35 views

Is it possible to disable showing `-- VISUAL LINE --` hint in the command line?

As title: I have a plugin that needs to show something in cmdline but now the space is occupied by: -- VISUAL LINE -- Any hint to get rid of it?
  • 1,095
0 votes
1 answer
44 views

How to move buffer between tabs?

As title. And I also need to know how to specify a tab to move to. So I expect the syntax would look like this: :movebuf <buffer_id> <tab_id>
  • 1,095
0 votes
0 answers
12 views

Why `<C-h>` is mapped to backspace even if I remove all the insert-mode keymaps of `<C-h>`? [duplicate]

As title. I'm using NeoVim and there is a syntax to remove all mappings of specific key-comb. in specified mode: vim.keymap.del('i', '<C-h>') But after the call :imap <C-h> shows: i <C-...
  • 1,095
0 votes
1 answer
33 views

Is it possible to detect key-release event in NeoVim?

As title. I want to simulate the App-switching feature of macOS cmd+tab. To do so I need to detect the release of some key to trigger my lua function. Any idea?
  • 1,095
0 votes
1 answer
70 views

How to get the filename where the line of vimscript/lua is in?

As title. Say I have a line to create an augroup located in file git.lua. What I want to achieve is that that line will always create an augroup named git.lua without hard-coding it by the string &...
  • 1,095
1 vote
0 answers
62 views

Help setting up init.lua in Neovim, I'm a new user and don't understand the structure for plugins

First of all, I'm not a programmer, but a musician. I just happen to (kind of) know how to use the terminal, and I use a music notation/engraving program called LilyPond that works in the terminal. ...
1 vote
0 answers
216 views

Is it possible to set a vim.api.nvim_create_autocmd for a FileType (not just a pattern)?

Currently I'm using pattern in vim.api.nvim.create_autocmd(): vim.api.nvim_create_autocmd({ "BufEnter", "BufFilePost" }, { pattern = { "*.tf" }, callback = ...
0 votes
1 answer
104 views

How to move cursor one line down with API in the way like the default 'j'?

For example, I have this in the buffer: line1 .... A .... line2 B line3 .... C .... Follow these steps: At first it's in Normal mode and the cursor is under A Press j and the cursor will move to B ...
  • 151
0 votes
0 answers
211 views

I am currently configuring my Neovim setup, but I am only get it to work as a root user

Basically, I am creating a .config/nvim for Neovim on my M1 Macbook Pro (Monterey 12.6), and I using the iTerm2 terminal emulator. I am having to create the entire configuration as a root user because ...
0 votes
1 answer
33 views

How to highlight missing comma in lua files?

I often forget the comma between embedded table entries in lua code. t = { a = { "str" }, b = { { "str3", v = 1, } <<-- missing comma ...
  • 181
1 vote
0 answers
18 views

How to to get commmand completions for selection from a keymap?

The idea is to have a keybinding, which executes a lua/vimscript function to paste yanked text into the command line and then have the command completion showing suggestions or directly get the ...
  • 123
0 votes
0 answers
180 views

Add mapping to switch between keymaps

(Neo)VIM comes with a built in binding set in insert and command modes as CTRL-^ that can be used to toggle the use of :lmap mappings (see :help keymaps). I've been using this for years and it works ...
  • 2,175
0 votes
2 answers
905 views

Are vim.cmd() and vim.api.nvim_command() the same, if not, what are the differences?

I'm a little confused. Is vim.cmd just a shorthand for vim.api.nvim_command or are they used for different things?
2 votes
1 answer
303 views

How to call a command with remapping in neovim?

Say I have a normal mode mapping on key P, for sure it can be executed in command mode: :lua normal! P Now I want to do this in lua, so I tried: vim.cmd('normal! P') and NeoVim executed it as "...
  • 1,095
0 votes
0 answers
88 views

How can I color a certain character, using Lua or otherwise?

I want to color arbitrary characters. As an example, let's say we want to color whatever character is to the immediate right of the cursor. Suppose we have the line: int x = 5; and the cursor is on n,...
  • 3
0 votes
1 answer
115 views

Using Lua, how can I run a function whenever the cursor moves?

I want a function to fire whenever the cursor moves. How can I do this?
  • 3
1 vote
1 answer
139 views

Why does this mapping of g to gj give "'Undefined variable gj"?

E121: Undefined variable : gj E121: Undefined variable : gk local keymap = vim.keymap.set local default_opts = { noremap = true, silent = true } local expr_opts = { noremap = true, expr = true, ...
  • 113
0 votes
1 answer
48 views

NeoVim-LUA: can vim.b only hold read-only data?

I'm writing a plugin for NeoVim in Lua and I'm trying to keep the state of my plugin in the vim.b table: vim.b.myplugin = vim.b.myplugin or { "property" = "value", ... } ...
0 votes
1 answer
156 views

How to make a http (https) request with a lua plugin?

does anyone know if it is possible to install a Lua HTTPS library that I can access from a Lua plugin in Neovim to make HTTPS requests (POST)? And how would I install such a library? For example, to ...
1 vote
1 answer
39 views

Where is the text data stored during typing text in insert mode?

I would like to develop a small app in React and Nodejs that sends real-time typed text from my Nodejs/Express server to my React frontend. To do this, I would like to use socket.io. The text data is ...
0 votes
0 answers
105 views

What is the Lua equivalent of an <expr> mapping with the ternary operator (?:)?

I was trying to set up a keybinding for vsnip in NeoVIM using Lua. The docs provide a vimscript snippet that I've been unable to translate. What would be the Lua equivalent of: imap <expr> <...
1 vote
1 answer
184 views

Get byte length of current line in Lua

How do I get the length, in bytes, of the current line in Lua? vim.api.strlen('foo') doesn't work
  • 171
1 vote
1 answer
756 views

How to check if an external command exists in Lua

How do I translate this VimL code into Lua? if executable('rg') set grepprg=rg\ --vimgrep endif
  • 171
0 votes
0 answers
332 views

Neovim how to rexecute vim.fn.expand() every time a keymap is called?

I would like to create a keymap to edit files by my current path, while showing the directory path of the current file For example, if I was editing file: /Users/[username]/projects/test.py Clicking &...
  • 111
4 votes
1 answer
215 views

How to use -complete=lua for command-completion?

If you check the help for :command-completion, there is a line that reads: -complete=lua Lua expression But it does not give further instructions about how to use it, or how to provide a Lua ...
0 votes
1 answer
610 views

Reload function when sourcing init.lua

In "~/.config/nvim/lua/foo.lua" I have the following local M = {} function M.test() vim.notify("hello") end return M And then in my init.lua I have local test = require('foo')....
0 votes
1 answer
63 views

How to enter terminal buffer using command?

As title. Assume my cursor is already at the terminal buffer, but it's still in normal mode. I'm trying to use TermEnter to enter terminal mode when ever I switch to a terminal buffer.
  • 1,095
0 votes
1 answer
2k views

How to setup intelephense with neovim + lua?

I have 2 neovims, one with coc, and another with lua. In neovim with coc, intelephense works. I am working with wordpress, and i need intelephense. Nvim coc setup. plugins.vim Plug 'yaegassy/coc-...
  • 35
0 votes
1 answer
121 views

Attach to terminal buffer opened with termopen

I have the following Lua function: local function submit_diff(diff_msg_file) vim.fn.termopen("arc diff HEAD^ -F " .. diff_msg_file, { on_exit = function(_, exit_code, _) if ...
0 votes
2 answers
2k views

How to create a lua function that gets called for a vim (neovim) motion

Vim has the concept of actions, which can act on text objects via motions. For example diw will delete (the action) the inner word (the motion). I want to create a function that can be applied/...
3 votes
2 answers
2k views

How to remove vim trailing white space?

In Vim I used autocmd BufWritePre * :%s/\s\+$//e to delete trailing white space. Now, Neovim 0.7 has the new vim.api.nvim_create_autocmd. What is the correct syntax to update this autocmd in Lua? vim....
  • 143
2 votes
1 answer
3k views

Neovim Lua: Error while calling lua chunk [...] '' expected near 'local'

When I run Neovim (NVIM v0.6.1), I get Error detected while processing /home/ecarroll/.config/nvim/init.lua: E5113: Error while calling lua chunk: vim.lua:63: /home/ecarroll/.config/nvim/lua/plugins....
0 votes
0 answers
271 views

(Code review) Copying file path relative to cwd with the line number appended

I am replicating what PHPStorm and VSCode do by allowing me to copy the file path and line number (plus column) to clipboard. I have written a function in lua to do this, but, I wanted to ask about ...
0 votes
0 answers
272 views

How to get the current window horizontal padding?

Today I wrote this little utility function to resize my current window to a comfortable width: -- Resizes the current window to the maximum required width function M.resize_window() local padding =...
0 votes
1 answer
1k views

leader not working in visual mode in lua?

I am migrating from vimscript to lua for my keybindings and I have remapped the leader key as space: vim.g.mapleader = " " It works fine with all my key bindings. Except in visual mode. ...
  • 553