diff options
| author | erw7 <erw7.github@gmail.com> | 2020-02-05 17:19:29 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-05 00:19:29 -0800 |
| commit | 67df627f0a5552a6fc2751a98e4edfb3c62397d5 (patch) | |
| tree | ed0e443dc906605fd0e594a314db0d090623b4f8 /lua/nvim_lsp | |
| parent | [docgen] Update README.md (diff) | |
| download | nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.tar nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.tar.gz nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.tar.bz2 nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.tar.lz nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.tar.xz nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.tar.zst nvim-lspconfig-67df627f0a5552a6fc2751a98e4edfb3c62397d5.zip | |
clangd: fix root_dir problem #114
- On Windows an error occurred (#113).
- On non-Windows, it was always the directory where the file located.
Since 638dad178311e the following error occurs when opening a C source file on Windows:
E5108: Error executing lua shared.lua:427: root_dir: expected directory, got
C:\msys64\home\erw7\src\github.com\neovim\neovim\src\nvim\tui\tui.c
On Windows, the following result does not seem to be `nil`.
vim.loop.fs_stat('C:\\Windows\\System32\\notepad.exe\\.')
fix #113
Diffstat (limited to 'lua/nvim_lsp')
| -rw-r--r-- | lua/nvim_lsp/clangd.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lua/nvim_lsp/clangd.lua b/lua/nvim_lsp/clangd.lua index 34207e5a..8c9855df 100644 --- a/lua/nvim_lsp/clangd.lua +++ b/lua/nvim_lsp/clangd.lua @@ -2,11 +2,14 @@ local configs = require 'nvim_lsp/configs' local util = require 'nvim_lsp/util' local lsp = vim.lsp +local root_pattern = util.root_pattern("compile_commands.json", "compile_flags.txt", ".git") configs.clangd = { default_config = util.utf8_config { cmd = {"clangd", "--background-index"}; filetypes = {"c", "cpp", "objc", "objcpp"}; - root_dir = util.root_pattern("compile_commands.json", "compile_flags.txt", ".git", "."); + root_dir = function(fname) + return root_pattern(fname) or util.path.dirname(fname) + end; log_level = lsp.protocol.MessageType.Warning; settings = {}; }; @@ -23,7 +26,7 @@ clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONC as compile_commands.json or, for simpler projects, a compile_flags.txt. ]]; default_config = { - root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or cwd]]; + root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]]; on_init = [[function to handle changing offsetEncoding]]; capabilities = [[default capabilities, with offsetEncoding utf-8]]; }; |
