-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.lua
150 lines (126 loc) · 4.79 KB
/
config.lua
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
-- Read the docs: https://www.lunarvim.org/docs/configuration
-- Example configs: https://github.com/LunarVim/starter.lvim
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
-- Forum: https://www.reddit.com/r/lunarvim/
-- Discord: https://discord.com/invite/Xb9B4Ny
-- My stuff
-- nav lvim tabs with gT / gt
lvim.keys.normal_mode["gt"] = ":BufferLineCycleNext<CR>"
lvim.keys.normal_mode["gT"] = ":BufferLineCyclePrev<CR>"
-- hop
lvim.keys.normal_mode["f"] = ":HopPattern<CR>"
lvim.keys.normal_mode["<leader><leader>t"] = ":HopChar1<CR>"
vim.api.nvim_create_user_command("Flash", function()
vim.cmd("!make flash")
end, {})
-- CPP stuff (from example config)
lvim.format_on_save = false
vim.diagnostic.config({ virtual_text = true })
lvim.builtin.treesitter.highlight.enable = true
-- auto install treesitter parsers
lvim.builtin.treesitter.ensure_installed = { "cpp", "c" }
-- Additional Plugins
table.insert(lvim.plugins, {
"p00f/clangd_extensions.nvim",
{
"smoka7/hop.nvim",
config = function()
require 'hop'.setup {}
end
},
"kana/vim-textobj-user",
{
"kana/vim-textobj-entire",
dependencies = "kana/vim-textobj-user"
}
})
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })
-- some settings can only passed as commandline flags, see `clangd --help`
local clangd_flags = {
"--background-index",
"--fallback-style=Google",
"--all-scopes-completion",
"--clang-tidy",
"--log=error",
"--suggest-missing-includes",
"--cross-file-rename",
"--completion-style=detailed",
"--pch-storage=memory", -- could also be disk
"--folding-ranges",
"--enable-config", -- clangd 11+ supports reading from .clangd configuration file
"--offset-encoding=utf-16", --temporary fix for null-ls
-- "--query-driver="..avr_gcc,
-- "--limit-references=1000",
-- "--limit-resutls=1000",
-- "--malloc-trim",
-- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type",
-- "--header-insertion=never",
-- "--query-driver=<list-of-white-listed-complers>"
}
local provider = "clangd"
local custom_on_attach = function(client, bufnr)
require("lvim.lsp").common_on_attach(client, bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "<leader>lh", "<cmd>ClangdSwitchSourceHeader<cr>", opts)
vim.keymap.set("x", "<leader>lA", "<cmd>ClangdAST<cr>", opts)
vim.keymap.set("n", "<leader>lH", "<cmd>ClangdTypeHierarchy<cr>", opts)
vim.keymap.set("n", "<leader>lt", "<cmd>ClangdSymbolInfo<cr>", opts)
vim.keymap.set("n", "<leader>lm", "<cmd>ClangdMemoryUsage<cr>", opts)
require("clangd_extensions.inlay_hints").setup_autocmd()
require("clangd_extensions.inlay_hints").set_inlay_hints()
end
local status_ok, project_config = pcall(require, "rhel.clangd_wrl")
if status_ok then
clangd_flags = vim.tbl_deep_extend("keep", project_config, clangd_flags)
end
local custom_on_init = function(client, bufnr)
require("lvim.lsp").common_on_init(client, bufnr)
require("clangd_extensions.config").setup {}
require("clangd_extensions.ast").init()
vim.cmd [[
command ClangdToggleInlayHints lua require('clangd_extensions.inlay_hints').toggle_inlay_hints()
command -range ClangdAST lua require('clangd_extensions.ast').display_ast(<line1>, <line2>)
command ClangdTypeHierarchy lua require('clangd_extensions.type_hierarchy').show_hierarchy()
command ClangdSymbolInfo lua require('clangd_extensions.symbol_info').show_symbol_info()
command -nargs=? -complete=customlist,s:memuse_compl ClangdMemoryUsage lua require('clangd_extensions.memory_usage').show_memory_usage('<args>' == 'expand_preamble')
]]
end
local opts = {
cmd = { provider, unpack(clangd_flags) },
on_attach = custom_on_attach,
on_init = custom_on_init,
}
require("lvim.lsp.manager").setup("clangd", opts)
-- install codelldb with :MasonInstall codelldb
-- configure nvim-dap (codelldb)
lvim.builtin.dap.on_config_done = function(dap)
dap.adapters.codelldb = {
type = "server",
port = "${port}",
executable = {
-- provide the absolute path for `codelldb` command if not using the one installed using `mason.nvim`
command = "codelldb",
args = { "--port", "${port}" },
-- On windows you may have to uncomment this:
-- detached = false,
},
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
local path
vim.ui.input({ prompt = "Path to executable: ", default = vim.loop.cwd() .. "/build/" }, function(input)
path = input
end)
vim.cmd [[redraw]]
return path
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
},
}
dap.configurations.c = dap.configurations.cpp
end