aboutsummaryrefslogtreecommitdiffstats
path: root/lua/common_lsp/util.lua
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-14 00:04:56 -0800
committerAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-14 00:04:56 -0800
commit7fbe851feb26529434b64d8fb3a30f5bb01f180c (patch)
treeb8d81bff4b77b93eeadffa2afa57b59f67f06a7f /lua/common_lsp/util.lua
parentAdd note about gopls (diff)
downloadnvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.tar
nvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.tar.gz
nvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.tar.bz2
nvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.tar.lz
nvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.tar.xz
nvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.tar.zst
nvim-lspconfig-7fbe851feb26529434b64d8fb3a30f5bb01f180c.zip
Use new skeleton. Add docs generator.
Diffstat (limited to 'lua/common_lsp/util.lua')
-rw-r--r--lua/common_lsp/util.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/lua/common_lsp/util.lua b/lua/common_lsp/util.lua
index 9aed25fe..6cc6db0f 100644
--- a/lua/common_lsp/util.lua
+++ b/lua/common_lsp/util.lua
@@ -84,7 +84,7 @@ function M.create_module_commands(module_name, commands)
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))
+ string.format("lua require'common_lsp'[%q].commands[%q][1]()", module_name, command_name))
api.nvim_command(table.concat(parts, " "))
end
end
@@ -123,6 +123,7 @@ M.path = (function()
local strip_dir_pat = path_sep.."([^"..path_sep.."]+)$"
local strip_sep_pat = path_sep.."$"
dirname = function(path)
+ if not path then return end
local result = path:gsub(strip_sep_pat, ""):gsub(strip_dir_pat, "")
if #result == 0 then
return "/"
@@ -142,6 +143,7 @@ M.path = (function()
-- Just in case our algo is buggy, don't infinite loop.
for _ = 1, 100 do
dir = dirname(dir)
+ if not dir then return end
-- If we can't ascend further, then stop looking.
if cb(dir, path) then
return dir, path
@@ -156,6 +158,7 @@ M.path = (function()
local function iterate_parents(path)
path = uv.fs_realpath(path)
local function it(s, v)
+ if not v then return end
if is_fs_root(v) then return end
return dirname(v), path
end