Questions tagged [lua]

Question about the Lua binding in Neovim

58 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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
2 votes
1 answer
67 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 ...
Piet Pro's user avatar
2 votes
0 answers
1k views

Neovim - How do you call Python from Lua and store the results as a Lua variable?

I am trying to improve a GitHub repository for Neovim called quangnguyen30192/cmp-nvim-ultisnips It's a Lua repository that calls another Vim plugin repository, SirVer/ultisnips , a primarily Python-...
ColinKennedy's user avatar
2 votes
0 answers
667 views

Cannot get current node tree with treesitter in Lua in nvim

I am trying to get the AST tree to find the node I want. Based on the doc, I should be able to get the tree like this: local parser = vim.treesitter.get_parser(0, vim.o.filetype) print('check ...
John Winston's user avatar
1 vote
0 answers
11 views

How can I jump to a sibling node in Neovim?

Say I want to write a custom function / keyboard shortcut to jump to the next sibling node in Neovim/Lua. In theory, I can get that with TSNode:next_sibling(). But I'm lost as to how I would put the ...
Sasgorilla's user avatar
1 vote
1 answer
45 views

Using a single carret character as the fold character in Neovim using Lua

I am using Neovim v0.9.5 and configured this editor using Lua. I'm searching for a way of using a single caret down (▾) character for folds. Here is what is currently used by Neovim by default. ** ...
Amin NAIRI's user avatar
1 vote
0 answers
324 views

How to lazy-load `oil.nvim` on `FileExplorer` event?

I have next oil.nvim setup (in lazy.nvim of course): return { { 'stevearc/oil.nvim', cmd = { "Oil" }, event = { "FileExplorer" }, opts = { ...
Vladyslav Rehan's user avatar
1 vote
0 answers
50 views

How can I handle whitespace of the path with nvim_buf_get_name?

I am using Neovim and I use this code to get the full path of the current file. local currnetPath=vim.api.nvim_buf_get_name(0) I want to use this variable for opening the current HTML file, so I need ...
mohamadi_arch's user avatar
1 vote
1 answer
922 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
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
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
0 answers
334 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. ...
Kai Vinter's user avatar
1 vote
0 answers
44 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 ...
Jay-Pi's user avatar
  • 123
1 vote
0 answers
445 views

How does .vimrc relate to ~/.config/nvim/init.lua?

When I heard neovim had a "native language client", I wanted to trying moving it. Previously, I was using a language server loaded through vim-plug. This was always problematic. When I ...
Evan Carroll's user avatar
  • 1,304
1 vote
0 answers
155 views

How to run command asynchronously whith :lua command?

When using vim8.1, it does not provide vim.fn and vim.call function, so we can not use vim.fn.job_start. then how can I run command asynchronously in lua?
Eric Wong's user avatar
  • 530
1 vote
0 answers
372 views

stash and restore highlight colors with lua and neovim

I would like to toggle an option and with it the highlight color of Whitespace. Before setting the color with vim.api.nvim_command("hi Whitespace guifg=#ff0000") I would like to stash the ...
Pierre's user avatar
  • 11
0 votes
0 answers
20 views

Set the current line limit for jumping in Vim

I want to set a limit for the use of e. Basically e is for jumping forward to the end of words, but I do not want to go to the next line. I just want to jump to the end of all the words in the current ...
mohamadi_arch's user avatar
0 votes
0 answers
15 views

Creating a faster way to <next error> -> <suggest fix> -> <accept fix>

I'm using lazyvim with clangd extra installed, and when I have an error / diagnostic that needs handling I do the following routine: ]d / ]e (go to next diagnostic / error) <LEADER>ca (i.e. ...
CIsForCookies's user avatar
0 votes
0 answers
29 views

":term" style completion in vim.ui.input()

I currently have the following keymap: vim.keymap.set('n', '<leader>sr', function() return ":vs | term " end, { expr = true }) This drops me into a vim command where I can complete ...
Kurtis Nusbaum's user avatar
0 votes
0 answers
28 views

How to get/print all max-nested non-empty subdirs starting from some path(dir)?

How to get/print all max-nested non-empty subdirs starting from path(dir)? I found a random option to do this on Linux (bash): find ~/.config/nvim -type f | sed 's%/[^/]*$%%' | sort -u But I'm ...
cuc's user avatar
  • 1
0 votes
0 answers
21 views

Can you trigger a specific lsp code action programmicaly?

Doing the equivalent of :lua vim.lsp.buf.code_action() And pressing a key. I tried some variants like :lua vim.lsp.buf.code_action() :sleep 5 :call feedkeys('4','t') doesn't seem to work.
eyal karni's user avatar
  • 1,106
0 votes
1 answer
52 views

How to display a colored file icon in the statusline?

So I was setting up my status line and I wanted a function which gives the icon of current file type. But it has to be in string. provider=function() str="{some icon}" return str end so ...
Prajwal 's user avatar
0 votes
0 answers
49 views

input with completion in times of lua (nvim-cmp ?)

let user_dir = input('Enter a directory: ', '', 'dir') This is simple not working for me. When I press <tab> instead of completion, I get ^I . I use nvim-cmp. Could it be the reason? Can I use ...
eyal karni's user avatar
  • 1,106
0 votes
0 answers
42 views

How can I get text inside double brackets under cursor in Lua?

I'm trying to write a simple little function to follow markdown wiki links of the form [[wiki link]]. I have a bunch of markdown notes with links of this type and they all link to files with the .md ...
ln4lar's user avatar
  • 101
0 votes
0 answers
40 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
  • 353
0 votes
0 answers
316 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
279 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
0 votes
1 answer
910 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
289 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
46 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
21 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
0 votes
0 answers
83 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
0 votes
1 answer
246 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
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
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
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
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
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
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
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
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
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
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

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 ...
anonymous017's user avatar
0 votes
1 answer
72 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 ...
Mattia72's user avatar
  • 191