diff options
| author | Marco Hinz <mh.codebro@gmail.com> | 2021-04-04 21:39:51 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-04-05 15:41:00 +0200 |
| commit | b8f17f89fb97138d6e15f08d42a0cd4815b3f917 (patch) | |
| tree | 0c045cd1ef11d1921f9fc42d908b9c5e8ad9c65d /lua | |
| parent | Comment: highlight text nodes (diff) | |
| download | nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.tar nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.tar.gz nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.tar.bz2 nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.tar.lz nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.tar.xz nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.tar.zst nvim-treesitter-b8f17f89fb97138d6e15f08d42a0cd4815b3f917.zip | |
TSModuleInfo: sort mods and languages
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/info.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lua/nvim-treesitter/info.lua b/lua/nvim-treesitter/info.lua index bfa44b505..6c63b8232 100644 --- a/lua/nvim-treesitter/info.lua +++ b/lua/nvim-treesitter/info.lua @@ -37,15 +37,20 @@ local function print_info_module(sorted_languages, mod) end end -local function print_info_modules(sorted_languages) - local max_str_len = #sorted_languages[1] +local function print_info_modules(parserlist) + table.sort(parserlist, function(a, b) return #a > #b end) + local max_str_len = #parserlist[1] + local header = string.rep(' ', max_str_len + 2) - for _, mod in pairs(configs.available_modules()) do + local mods = configs.available_modules() + table.sort(mods) + for _, mod in pairs(mods) do header = string.format('%s%s ', header, mod) end api.nvim_out_write(header..'\n') - for _, lang in pairs(sorted_languages) do + table.sort(parserlist) + for _, lang in pairs(parserlist) do local padding = string.rep(' ', max_str_len - #lang) api.nvim_out_write(lang..":"..padding) @@ -68,7 +73,6 @@ local function module_info(mod) if mod and not configs.get_module(mod) then return end local parserlist = parsers.available_parsers() - table.sort(parserlist, function(a, b) return #a > #b end) if mod then print_info_module(parserlist, mod) else |
