summaryrefslogtreecommitdiff
path: root/.nvim.lua
blob: 761bed0976332548960cae2ccf41d4f3d16eba7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- Formatting
vim.g.autoformat = true
vim.opt.fixeol = false
local function safe_require(module)
  local ok, mod = pcall(require, module)
  if not ok then return nil end
  return mod
end

-- C++
local default_clangd_config = vim.deepcopy(vim.lsp.config["clangd"]) or {}
default_clangd_config.cmd = {
  "clangd",
  "--background-index",
  "--clang-tidy",
  "--header-insertion=iwyu",
  "--completion-style=detailed",
}

vim.lsp.config("clangd", default_clangd_config)

-- File Browser
local neo_tree = safe_require("neo-tree")
if neo_tree then
  local current_config = neo_tree.config or {}
  local project_config = vim.tbl_deep_extend("force", current_config, {
    nesting_rules = {
      ['*.hpp'] = {
        pattern = "(.*).hpp",
        files = { "%1.cpp", "%1.tests.cpp" }
      }
    }
  })
  neo_tree.setup(project_config)
end