change rust client

This commit is contained in:
DefectingCat
2024-02-26 13:21:43 +08:00
parent ad679e1280
commit 3339ffb086
4 changed files with 87 additions and 44 deletions

View File

@ -1,8 +1,8 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require "lspconfig"
local util = require "lspconfig/util"
local lspconfig = require("lspconfig")
local util = require("lspconfig/util")
local function organize_imports()
local params = {
@ -12,16 +12,66 @@ local function organize_imports()
vim.lsp.buf.execute_command(params)
end
require("mason-lspconfig").setup_handlers {
require("mason-lspconfig").setup_handlers({
function(server)
lspconfig[server].setup {
lspconfig[server].setup({
on_attach = on_attach,
capabilities = capabilities,
}
})
end,
}
})
lspconfig.tsserver.setup {
lspconfig.rust_analyzer.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
["rust-analyzer"] = {
standalone = true,
files = {
excludeDirs = {
".flatpak-builder",
"_build",
".dart_tool",
".flatpak-builder",
".git",
".gitlab",
".gitlab-ci",
".gradle",
".idea",
".next",
".project",
".scannerwork",
".settings",
".venv",
"archetype-resources",
"bin",
"hooks",
"node_modules",
"po",
"screenshots",
"target",
"out",
"../out",
"../node_modules",
"../.next",
},
},
},
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
},
check = {
allTargets = false,
},
},
})
lspconfig.tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
init_options = {
@ -35,9 +85,9 @@ lspconfig.tsserver.setup {
description = "Organize Imports",
},
},
}
})
lspconfig.pylsp.setup {
lspconfig.pylsp.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = { "python" },
@ -51,9 +101,9 @@ lspconfig.pylsp.setup {
},
},
},
}
})
lspconfig.gopls.setup {
lspconfig.gopls.setup({
on_attach = on_attach,
capabilities = capabilities,
cmd = { "gopls" },
@ -71,9 +121,9 @@ lspconfig.gopls.setup {
},
},
},
}
})
lspconfig.jsonls.setup {
lspconfig.jsonls.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
@ -82,9 +132,9 @@ lspconfig.jsonls.setup {
validate = { enable = true },
},
},
}
})
lspconfig.yamlls.setup {
lspconfig.yamlls.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
@ -99,4 +149,4 @@ lspconfig.yamlls.setup {
schemas = require("schemastore").yaml.schemas(),
},
},
}
})

View File

@ -1,19 +1,19 @@
vim.g.rustaceanvim = function()
local mason_registry = require "mason-registry"
local codelldb = mason_registry.get_package "codelldb"
local mason_registry = require("mason-registry")
local codelldb = mason_registry.get_package("codelldb")
local extension_path = codelldb:get_install_path() .. "/extension/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = ""
if vim.loop.os_uname().sysname:find "Windows" then
if vim.loop.os_uname().sysname:find("Windows") then
liblldb_path = extension_path .. "lldb\\bin\\liblldb.dll"
elseif vim.fn.has "mac" == 1 then
elseif vim.fn.has("mac") == 1 then
liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
else
liblldb_path = extension_path .. "lldb/lib/liblldb.so"
end
local cfg = require "rustaceanvim.config"
local cfg = require("rustaceanvim.config")
return {
tools = {
hover_actions = {
@ -47,31 +47,24 @@ vim.g.rustaceanvim = function()
"po",
"screenshots",
"target",
"out",
"../out",
"../node_modules",
"../.next",
},
},
},
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
runBuildScripts = true,
},
--[[ checkOnSave = {
allFeatures = true,
command = "clippy",
}, ]]
--[[ check = {
command = "clippy",
features = "all",
extraArgs = { "--no-deps" },
}, ]]
--[[ procMacro = {
enable = true,
procMacro = {
enable = false,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
}, ]]
},
check = {
allTargets = false,
},
},
},
dap = {

View File

@ -162,14 +162,14 @@ local plugins = {
require("rust-tools").setup(opts)
end,
}, ]]
{
--[[ {
"mrcjkb/rustaceanvim",
version = "^3", -- Recommended
ft = { "rust" },
ft = "rust",
config = function()
require("custom.configs.rust")
end,
},
}, ]]
{
"saecki/crates.nvim",
ft = { "toml" },

View File

@ -39,9 +39,9 @@ autocmd("BufEnter", {
-- Triger `autoread` when files changes on disk
-- https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
-- https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
command = [[silent! if mode() != 'c' && !bufexists("[Command Line]") | checktime | endif]],
})
-- autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
-- command = [[silent! if mode() != 'c' && !bufexists("[Command Line]") | checktime | endif]],
-- })
-- Notification after file change
-- https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread