diff options
| author | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-14 00:50:01 -0800 |
|---|---|---|
| committer | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-14 00:50:01 -0800 |
| commit | 8bb6448e79e94e8d1bca715d8dda3ce6e850bf18 (patch) | |
| tree | de22c9d3e2636259464a7d71c00938370ec627c9 /lua | |
| parent | Bugfix (diff) | |
| download | nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.tar nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.tar.gz nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.tar.bz2 nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.tar.lz nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.tar.xz nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.tar.zst nvim-lspconfig-8bb6448e79e94e8d1bca715d8dda3ce6e850bf18.zip | |
Add contributing docs and clangd config.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/common_lsp.lua | 1 | ||||
| -rw-r--r-- | lua/common_lsp/clangd.lua | 40 | ||||
| -rw-r--r-- | lua/common_lsp/gopls.lua | 2 |
3 files changed, 42 insertions, 1 deletions
diff --git a/lua/common_lsp.lua b/lua/common_lsp.lua index eafd5e2c..4dea8e1e 100644 --- a/lua/common_lsp.lua +++ b/lua/common_lsp.lua @@ -1,6 +1,7 @@ local skeleton = require 'common_lsp/skeleton' require 'common_lsp/gopls' require 'common_lsp/texlab' +require 'common_lsp/clangd' local M = { util = require 'common_lsp/util'; diff --git a/lua/common_lsp/clangd.lua b/lua/common_lsp/clangd.lua new file mode 100644 index 00000000..465af674 --- /dev/null +++ b/lua/common_lsp/clangd.lua @@ -0,0 +1,40 @@ +local skeleton = require 'common_lsp/skeleton' +local util = require 'common_lsp/util' +local lsp = vim.lsp + +local default_capabilities = lsp.protocol.make_client_capabilities() +default_capabilities.offsetEncoding = {"utf-8", "utf-16"} + +skeleton.clangd = { + default_config = { + cmd = {"clangd", "--background-index"}; + filetypes = {"c", "cpp", "objc", "objcpp"}; + root_dir = util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"); + log_level = lsp.protocol.MessageType.Warning; + settings = {}; + capabilities = default_capabilities; + on_init = vim.schedule_wrap(function(client, result) + if result.offsetEncoding then + client.offset_encoding = result.offsetEncoding + end + end) + }; + -- commands = {}; + -- on_new_config = function(new_config) end; + -- on_attach = function(client, bufnr) end; + docs = { + description = [[ +https://clang.llvm.org/extra/clangd/Installation.html + +clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified +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")]]; + on_init = [[function to handle changing offsetEncoding]]; + capabilities = [[default capabilities, with offsetEncoding utf-8]]; + }; + }; +} +-- vim:et ts=2 sw=2 + diff --git a/lua/common_lsp/gopls.lua b/lua/common_lsp/gopls.lua index 306c7f2c..e3061d16 100644 --- a/lua/common_lsp/gopls.lua +++ b/lua/common_lsp/gopls.lua @@ -19,7 +19,7 @@ https://github.com/golang/tools/tree/master/gopls Google's lsp server for golang. ]]; default_config = { - root_dir = "vim's starting directory"; + root_dir = [[root_pattern("go.mod", ".git")]]; }; }; } |
