diff options
| author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-03-02 12:28:47 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-02 12:28:47 +0900 |
| commit | 3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac (patch) | |
| tree | eab715799aac3b537ee3228f61ed1a911c527cb7 /lua/nvim_lsp | |
| parent | Merge pull request #146 from mhartington/feat-html-lsp (diff) | |
| parent | [docgen] Update README.md (diff) | |
| download | nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.tar nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.tar.gz nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.tar.bz2 nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.tar.lz nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.tar.xz nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.tar.zst nvim-lspconfig-3bcc387ce69a97bf4cb5a1fa75aa7923ae30f5ac.zip | |
Merge pull request #153 from erw7/fix-clangd-root-dir2
Fix clangd issue on Windows
Diffstat (limited to 'lua/nvim_lsp')
| -rw-r--r-- | lua/nvim_lsp/clangd.lua | 4 | ||||
| -rw-r--r-- | lua/nvim_lsp/util.lua | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lua/nvim_lsp/clangd.lua b/lua/nvim_lsp/clangd.lua index 59649f8e..34389721 100644 --- a/lua/nvim_lsp/clangd.lua +++ b/lua/nvim_lsp/clangd.lua @@ -7,7 +7,9 @@ configs.clangd = { cmd = {"clangd", "--background-index"}; filetypes = {"c", "cpp", "objc", "objcpp"}; root_dir = function(fname) - return root_pattern(fname) or util.path.dirname(fname) + local filename = util.path.is_absolute(fname) and fname + or util.path.join(vim.loop.cwd(), fname) + return root_pattern(filename) or util.path.dirname(filename) end; }; -- commands = {}; diff --git a/lua/nvim_lsp/util.lua b/lua/nvim_lsp/util.lua index 433bcab2..82767905 100644 --- a/lua/nvim_lsp/util.lua +++ b/lua/nvim_lsp/util.lua @@ -128,6 +128,14 @@ M.path = (function() end end + local function is_absolute(filename) + if is_windows then + return filename:match("^%a:") or filename:match("^\\\\") + else + return filename:match("^/") + end + end + local dirname do local strip_dir_pat = path_sep.."([^"..path_sep.."]+)$" @@ -195,6 +203,7 @@ M.path = (function() return { is_dir = is_dir; is_file = is_file; + is_absolute = is_absolute; exists = exists; sep = path_sep; dirname = dirname; |
