aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorSantos Gallegos <stsewd@protonmail.com>2021-04-16 00:51:40 -0500
committerGitHub <noreply@github.com>2021-04-16 00:51:40 -0500
commit2abad14069534f5589cab43f744cdf7be93a5464 (patch)
treed10b69826a88b2ecacbea9ea503e8e73d855dd76 /lua
parentremove developer mode error message (diff)
downloadnvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.tar
nvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.tar.gz
nvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.tar.bz2
nvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.tar.lz
nvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.tar.xz
nvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.tar.zst
nvim-treesitter-2abad14069534f5589cab43f744cdf7be93a5464.zip
Fix TSEditQuery with several files (#1191)
- Choice already starts with 1, there isn't need to increment 1 - The first item is the prompt as recommended in `:h inputlist()` (this way the choice matches when using the mouse)
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/configs.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua
index 1cc9756ee..333cf003d 100644
--- a/lua/nvim-treesitter/configs.lua
+++ b/lua/nvim-treesitter/configs.lua
@@ -207,9 +207,18 @@ function M.edit_query_file(query_group, lang)
vim.cmd(':edit '..files[1])
else
local counter = 0
- local choice = vim.fn.inputlist(vim.tbl_map(function(f) counter = counter + 1;return counter..'. '..f end, files))
- if choice > 0 then
- vim.cmd(':edit '..files[choice + 1])
+ local choices = {
+ 'Select a file:',
+ table.unpack(vim.tbl_map(function(f)
+ counter = counter + 1
+ return counter..'. '..f
+ end,
+ files
+ ))
+ }
+ local choice = vim.fn.inputlist(choices)
+ if choice > 0 and choice <= #files then
+ vim.cmd(':edit '..files[choice])
end
end
end