dotfiles/nvim/.config/nvim/after/ftplugin/c.lua
Sanchayan Maity 9a26ef9c10 nvim: Drop nvim-lspconfig
Use the new vim.lsp.start API and LspAttach/Detach auto commands.
Drop nvim-lspconfig in the process.

LSP server specific configuration has been taken from nvim-lspconfig.
2022-08-31 12:21:28 +05:30

23 lines
730 B
Lua

local default_capabilities = {
textDocument = {
completion = {
editsNearCursor = true,
},
},
offsetEncoding = { 'utf-8', 'utf-16' },
}
local root_files = { '.clangd', '.clang-tidy', '.clang-format', 'compile_commands.json', 'compile_flags.txt' }
local clangd_cmd = { "clangd", "--background-index", "--pch-storage=memory", "--clang-tidy", "--header-insertion=never" }
local path = vim.fs.find(root_files, { type = "file" })
local root = vim.fs.dirname(path[1])
vim.lsp.start({
name = "clangd",
cmd = clangd_cmd,
root_dir = root,
filetypes = { 'c', 'cpp' },
single_file_support = true,
capabilities = default_capabilities,
})