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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
local on_attach = require('myConfig.exports').on_attach
vim.g.rustaceanvim = {
-- Plugin configuration
tools = {
},
-- LSP configuration
server = {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
vim.keymap.set(
-- {"n", "v"},
"n",
"J",
function() vim.cmd.RustLsp('joinLines') end,
{
silent = true,
buffer = bufnr,
desc = "rust-analyzer join lines",
}
)
vim.keymap.set(
"n",
"<M-Up>",
function() vim.cmd.RustLsp({ "moveItem", "up" }) end,
{
silent = true,
buffer = bufnr,
desc = "rust-analyzer move item up",
}
)
vim.keymap.set(
"n",
"<M-Down>",
function() vim.cmd.RustLsp({ "moveItem", "down" }) end,
{
silent = true,
buffer = bufnr,
desc = "rust-analyzer move item down",
}
)
vim.keymap.set(
"n",
"<leader>sR",
function() vim.cmd.RustLsp('runnables') end,
{
silent = true,
buffer = bufnr,
desc = "rust-analyzer runnables",
}
)
vim.keymap.set(
"n",
"<leader>sx",
function() vim.cmd.RustLsp('explainError') end,
{
silent = true,
buffer = bufnr,
desc = "rust-analyzer explain error",
}
)
end,
settings = {
['rust-analyzer'] = {
checkOnSave = {
command = "clippy",
},
experimental = {
procAttrMacros = true,
},
},
},
},
}
-- clangd
require("clangd_extensions.inlay_hints").setup_autocmd()
require("clangd_extensions.inlay_hints").set_inlay_hints()
require("neodev").setup({})
-- Refactoring
require("refactoring").setup {}
-- Null LSP
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.code_actions.gitrebase,
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.code_actions.refactoring.with {
filetypes = { "typescript", "javascript", "lua", "c", "cpp", "go", "python", "java", "php", "ruby" },
},
null_ls.builtins.code_actions.statix,
null_ls.builtins.diagnostics.deadnix,
null_ls.builtins.diagnostics.statix,
null_ls.builtins.diagnostics.vale.with {
filetypes = { "markdown", "pandoc", "rst", "tex", "asciidoc" },
},
null_ls.builtins.formatting.alejandra,
null_ls.builtins.formatting.shfmt,
},
on_attach = on_attach,
})
-- Vim Pandoc
vim.g["pandoc#formatting#equalprg"] = "pandoc -t markdown --wrap=preserve"
-- standalone needed to keep the YAML metadata block
vim.g["pandoc#formatting#extra_equalprg"] = "--standalone --reference-links --reference-location=section"
-- Actions preview
require("actions-preview").setup()
-- DAP
-- require("dapui").setup()
-- require("nvim-dap-virtual-text").setup()
-- require('telescope').load_extension('dap')
-- LTex
local function set_ltex_lang(lang)
local ltex = vim.lsp.get_active_clients({ name = "ltex" })[1]
if ltex == nil then
return
end
if lang == nil then
lang = vim.opt_local.spelllang:get()[1]
end
if lang == "en" then
lang = "en-US"
end
ltex.config.settings.ltex.language = lang
end
vim.api.nvim_create_user_command(
"LTeXSetLang",
function(opts)
local lang = opts.fargs[1]
set_ltex_lang(lang)
end,
{
nargs = 1,
complete = function() return { "en", "fr" } end,
}
)
vim.api.nvim_create_autocmd("OptionSet", {
desc = "Set LTex language on spell change",
callback = function(ev)
if ev.match ~= "spelllang" then
return
end
set_ltex_lang()
end,
})
vim.api.nvim_create_autocmd("LspAttach", {
desc = "Set LTex language on attach",
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client.config.name ~= "ltex" then
return
end
set_ltex_lang()
end,
})
-- TODO: implement custom client-side commands like:
--
-- vim.lsp.commands["_ltex.addToDictionary"] = function(params)
-- print(vim.inspect(params))
-- end
--
-- See: https://valentjn.github.io/ltex/ltex-ls/server-usage.html#commands
|