Questions tagged [vimscript-lua]

Lua programming interface to Vim. DO NOT use for questions with Lua examples or about syntax highlighting in Lua.

Filter by
Sorted by
Tagged with
0 votes
1 answer
31 views

How to get the scrolloff set by user in Lua for NeoVim?

As title. I'm fixing a plugin and I need to know the scrolloff set by user.
  • 811
0 votes
0 answers
16 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 ...
0 votes
1 answer
52 views

Passing a count to a user command with neovim's Lua API

vim.api.nvim_create_user_command("TestCommand", function(opts) print(opts.count) end, { count = 1 }) vim.keymap.set("n", "<C-x>", "<cmd> TestCommand ...
  • 101
1 vote
1 answer
40 views

What's the effect of "range" on :lua and :luafile commands?

The :lua and :luafile commands take an optional [range] specification. But it's unclear what effect it has (unlike the :luado command, where the effect is explained clearly in the help text). Is ...
  • 123
0 votes
2 answers
923 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/...
0 votes
0 answers
152 views

Convert Vim keymap to lua

I want to change my emmet leader key in vim, but I do not know how to do this in lua. Vim Script code: imap ,, <C-y>, Lua Code: local map = vim.keymap.set
  • 1
0 votes
0 answers
84 views

Porting Asyncrun vimscript to lua

In my Vim's configuration file init.vim I am using code, that sets a default viewer for practically any kind of file suffix. Here I will demonstrate only an example for .md files: let g:...
  • 109
1 vote
1 answer
448 views

How to set keywordprg to call a lua function in neovim?

A plugin unidentified is setting the keywordprg option to :Man but I want it to be LSP based. So I attempted set keywordprg=:lua\ vim.lsp.buf.signature_help() but it gives me the following error and ...
0 votes
1 answer
394 views

See live word count in Lualine

I am currently using lualine as my statusline. I would like to see the live world count of the file similar to the feature in airline preferable I would like to get this working natively or else any ...
0 votes
0 answers
482 views

neovim: vim.fn is nil

I have a lua plugins script defining local fn = vim.fn. A couple of lines later it defines local install_path = fn.stdpath('data'). This script is called from my init.vim by lua require('plugins'). ...
1 vote
0 answers
683 views

LspConfig code action does not work

I have problems with LspConfig when extracting a method to a new file. When executing the following command buf_set_keymap("n","<space>ca","<cmd> lua vim.lsp.buf....
0 votes
0 answers
70 views

Cursorline became black when cursor is moving

If I change the colorscheme by <option>+12345 :colorscheme newsprint Then when I will firstly got the expected result: But then if I move my cursor by j/k, the clean cursorline gone: I can ...
  • 811
0 votes
1 answer
849 views

How to use packer.use inside neovim?

I was switching vimscript to lua in neovim, and I saw packer.nvim is a famous plugin manager for lua. In this README.md file I saw I can use startup function, but it's not required and I can also use ...
0 votes
1 answer
646 views

How to transform this Vimscript into Lua?

Can anyone help me transform this into nvim.lua? inoremap <silent><expr> <TAB> \ pumvisible() ? "<C-n>" : \ <SID>check_back_space() ? "<TAB&...
  • 811
0 votes
0 answers
126 views

How to require `luafile` not in a subdirectory

in my config of init.lua ,I want to load a luafile from anywhere or any directory so : can I source it without function vim.cmd() vim.cmd('luafile /full/path/to/file.lua')
0 votes
1 answer
72 views

How to colorize words in a buffer, using type data and position data?

I am writing a plugin for Neovim using Lua. If I have a text and some predefined arbitrary types, for example: chita wolf grizzly types: dog(green), cat(blue), bear(yellow) And I know positions/...
  • 135
0 votes
1 answer
666 views

How to use vim.loop interactively in Neovim?

I want to read texts with Neovim scrolling them down automatically. The following code provides such functionality: local M = {} function M.down() local timer = vim.loop.new_timer() local ...
  • 135
1 vote
1 answer
126 views

How to provide modifier keys in lua?

If I want to move a cursor one line down with Lua in Neovim I can use :lua vim.cmd('normal j') How do I move the screen down one line? For example, this does not work: :lua vim.cmd('normal \<C-E&...
  • 135
0 votes
0 answers
65 views

How to get strings between `[ and `] in lua?

I'm trying to play around with text objects in lua, here's what I got: https://learnvimscriptthehardway.stevelosh.com/chapters/33.html On that webpage, I found that I can operate on the text send to ...
0 votes
1 answer
139 views

How to call function with lisp style via mappings from lua in neovim?

I'm trying to use v:lua to call functions written in lua (actually it's fennel, which compiles to lua). Now I have a function named lisp-style , then I can't directly use v:lua.lisp-style() because it'...
1 vote
1 answer
151 views

how to tabdo all the visible buffers without changing the current tab?

My init.vim code: cd ~/Documents/cp nnoremap <leader>lcd :tabdo lcd %:p:h<cr> suppose, i have 4 tabs opened in nvim via using nvim -p A.cpp B.cpp C.cpp D.cpp A.cpp B.cpp C.cpp D.cpp ...
  • 121
-1 votes
2 answers
5k views

short key mapping by lua for neovim

the simple why to remap key in lua is: vim.api.nvim_set_keymap('n', 'foo', 'bar', { noremap = true, silent = true }) but i want a simple syntax like vimScript: nnoremap foo bar n_keymap('foo','bar') ...
2 votes
4 answers
4k views

Neovim lua config: how to append to listchars?

In a neovim init.lua config, I know that I can append to a string like so: vim.opt.wildignore:append("*/node_modules/*,*/vendor/*,*/venv/*,*/.venv/*,*/target/*") However, I'm getting errors ...
  • 181
0 votes
2 answers
46 views

Cycle through a list of letters in multiple groups

So I have a case where I have some unicode letters say [B, Ḅ, Ḃ] and when I have my mouse selected over the B, (in normal mode) I want some way of cycling through the list. Like pressing some command ...
2 votes
2 answers
1k views

Get value of $MYVIMRC from Lua

I am trying to retrieve the value of $MYVIMRC in my init.lua but I am coming up short because I don't understand what $MYVIMRC actually is. It is not a global variable, is it? None of these work: vim....
  • 123
1 vote
0 answers
497 views

Autoloaded vs lua functions: which is faster/more efficient?

I'm creating a neovim plugin written in Lua, and I have to react to the BufAdd and BufUnload events with a function call. I have 3 options: write the function in Lua (like the rest of the plugin) and ...
  • 159
0 votes
0 answers
43 views

Cannot search for pairs with searchpairpos()

I am trying to search for the location of the start and the end of a pair with searchpairpos(). Given an example like this: *hel[]lo* And my code like this: local start_match = vim.api....
2 votes
2 answers
4k views

How to modify only the background colour of a colourscheme in neovim using lua

I am slowly switching my neovim configurations to Lua. I am currently using the colour scheme https://github.com/nightsense/snow. It sets the background colour to a light-grey, while I want it to be a ...
  • 31
6 votes
1 answer
7k views

How to get the filetype in lua in nvim

How to get the current file type in lua with neovim? I tried following but all of them returns nil. print(vim.g.filetype) print(vim.b.filetype) print(vim.w.filetype) print(vim.t.filetype) print(vim.v....
  • 294
3 votes
1 answer
5k views

Most efficient way to call a Vim script function with lua (Neovim)

What is the most efficient way to call a Neovim function using Lua. I am able to call the sign_define Vim script function using the nvim_command procedure. I struggle with calling it with the ...
  • 149
4 votes
1 answer
2k views

Neovim Lua integration

I'm trying to understand how can I use Lua to extend Neovim, following a baby steps approach. Something like: -- ~/.config/nvim/lua/test.lua local api = vim.api local firstmodule = {} function ...
0 votes
0 answers
793 views

Adding directories to Lua’s search path

I’m trying to run Fennel scripts in Vim 8.1 using the fennel-nvim plugin. (Fennel is a language that basically lets you write Lua with LISP syntax; you can use it from any Lua-supporting application ...
  • 2,573
4 votes
2 answers
3k views

How to use Lua in Vim?

I'm using MacVim snapshot 134 (on Mac OS X 10.9.5), which has support for Lua: $ vim --version | grep lua +dialog_con_gui +lua/dyn +rightleft +writebackup I've got Lua installed and ...
  • 1,377
5 votes
1 answer
2k views

Is it possible to write .nvimrc for NeoVim in Lua?

Is it possible to write .nvimrc for NeoVim in Lua? Is it planned for the future?