From 740e27ec856cc688f0ecf0ffe2b55b26ce771407 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Wed, 7 Jul 2021 14:27:30 +0200 Subject: Add language support for linting and diagnostics --- .config/nvim/ftplugin/c.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .config/nvim/ftplugin/c.lua (limited to '.config/nvim/ftplugin/c.lua') diff --git a/.config/nvim/ftplugin/c.lua b/.config/nvim/ftplugin/c.lua new file mode 100644 index 0000000..7443cab --- /dev/null +++ b/.config/nvim/ftplugin/c.lua @@ -0,0 +1,20 @@ +local clangd_flags = { "--background-index" } + +if O.lang.clang.cross_file_rename then + table.insert(clangd_flags, "--cross-file-rename") +end + +table.insert(clangd_flags, "--header-insertion=" .. O.lang.clang.header_insertion) + +require("lspconfig").clangd.setup { + cmd = { DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd", unpack(clangd_flags) }, + on_attach = require("lsp").common_on_attach, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.lang.clang.diagnostics.virtual_text, + signs = O.lang.clang.diagnostics.signs, + underline = O.lang.clang.diagnostics.underline, + update_in_insert = true, + }), + }, +} -- cgit v1.2.3-70-g09d2