1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Merge 074a53a66451d3445031633599c9aaa7a5c80f95 into c7fb090e4ce94e72414169a247ac62f049d6b03b

This commit is contained in:
Li Peng 2025-01-04 01:01:42 +00:00 committed by GitHub
commit 47a651be55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View File

@ -278,6 +278,32 @@ if utils.executable("lua-language-server") then
}
end
-- settings for rust-analyzer is copied from https://rust-analyzer.github.io/manual.html#nvim-lsp
if utils.executable("rust-analyzer") then
lspconfig.rust_analyzer.setup {
on_attach = custom_attach,
settings = {
['rust-analyzer'] = {
imports = {
granularity = {
group = "module",
},
prefix = "self",
},
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true
},
},
},
capabilities = capabilities,
}
end
-- Change diagnostic signs.
fn.sign_define("DiagnosticSignError", { text = "🆇", texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = "⚠️", texthl = "DiagnosticSignWarn" })

View File

@ -54,6 +54,13 @@ api.nvim_create_autocmd({ "BufWritePre" }, {
end,
})
api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = {"*.c", "*.cc", "*.cpp", "*.h", "*.rs", "*.py"},
callback = function()
vim.lsp.buf.format { asnyc = false }
end,
})
-- Automatically reload the file if it is changed outside of Nvim, see https://unix.stackexchange.com/a/383044/221410.
-- It seems that `checktime` does not work in command line. We need to check if we are in command
-- line before executing this command, see also https://vi.stackexchange.com/a/20397/15292 .