diff options
| author | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-13 13:23:32 -0800 |
|---|---|---|
| committer | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-13 13:23:32 -0800 |
| commit | d3019b57aee89422600cdec6854403d645c90a06 (patch) | |
| tree | caead18169994bda21c173d4f7bf0823dfbf7582 /lua/common_lsp/util.lua | |
| parent | Improve the skeleton. (diff) | |
| download | nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.tar nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.tar.gz nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.tar.bz2 nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.tar.lz nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.tar.xz nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.tar.zst nvim-lspconfig-d3019b57aee89422600cdec6854403d645c90a06.zip | |
Improve skeleton
Diffstat (limited to 'lua/common_lsp/util.lua')
| -rw-r--r-- | lua/common_lsp/util.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lua/common_lsp/util.lua b/lua/common_lsp/util.lua index ee48b5d7..1aebbfb6 100644 --- a/lua/common_lsp/util.lua +++ b/lua/common_lsp/util.lua @@ -68,6 +68,27 @@ function M.lookup_section(settings, section) return settings end +function M.create_module_commands(module_name, commands) + for command_name, def in pairs(commands) do + local parts = {"command!"} + -- Insert attributes. + for k, v in pairs(def) do + if type(k) == 'string' and type(v) == 'boolean' and v then + table.insert(parts, "-"..k) + elseif type(k) == 'number' and type(v) == 'string' and v:match("^%-") then + table.insert(parts, v) + end + end + table.insert(parts, command_name) + -- The command definition. + table.insert(parts, + string.format("lua require'common_lsp/%s'.commands[%q][1]()", module_name, command_name)) + local command = table.concat(parts, " ") + print(command) + api.nvim_command(command) + end +end + return M -- vim:et ts=2 sw=2 |
