change nvimtree cr and simplify lsp config
This commit is contained in:
parent
948e1feea3
commit
a1d61a1144
@ -14,6 +14,19 @@ wk.register({
|
||||
["<Leader>S"] = { ":wa<CR>", "Save All" },
|
||||
})
|
||||
|
||||
-- lsp 回调快捷键设置
|
||||
pluginKeys.maplsp = function(mapbuf)
|
||||
-- go xx
|
||||
mapbuf("n", "]d", "<cmd>lua vim.lsp.buf.definition()<CR>", opt)
|
||||
-- mapbuf("n", "gh", "<cmd>lua vim.lsp.buf.hover()<CR>", opt)
|
||||
mapbuf("n", "]D", "<cmd>lua vim.lsp.buf.declaration()<CR>", opt)
|
||||
mapbuf("n", "]i", "<cmd>lua vim.lsp.buf.implementation()<CR>", opt)
|
||||
mapbuf("n", "]r", "<cmd>lua vim.lsp.buf.references()<CR>", opt)
|
||||
-- diagnostic
|
||||
mapbuf("n", "]p", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opt)
|
||||
mapbuf("n", "]n", "<cmd>lua vim.diagnostic.goto_next()<CR>", opt)
|
||||
end
|
||||
|
||||
-- code related
|
||||
-- 代码相关
|
||||
map("n", ",", ":RunCode<CR>", opt)
|
||||
|
35
lua/lsp/config/basic_config.lua
Normal file
35
lua/lsp/config/basic_config.lua
Normal file
@ -0,0 +1,35 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
require("keybindings").maplsp(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
@ -1,35 +1 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
-- end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
return require("lsp.config.basic_config")
|
||||
|
@ -1,35 +1 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
-- end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
return require("lsp.config.basic_config")
|
||||
|
@ -1,35 +1 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
-- end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
return require("lsp.config.basic_config")
|
||||
|
@ -49,13 +49,13 @@ local opts = {
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
require("keybindings").maplsp(buf_set_keymap)
|
||||
end,
|
||||
-- -- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- -- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
-- end,
|
||||
}
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
@ -1,35 +1 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
-- end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
return require("lsp.config.basic_config")
|
||||
|
@ -1,35 +1 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
-- end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
return require("lsp.config.basic_config")
|
||||
|
@ -1,35 +1 @@
|
||||
return {
|
||||
on_setup = function(server)
|
||||
server.setup({
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- 禁用格式化功能,交给专门插件插件处理
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "cursor",
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
-- local function buf_set_keymap(...)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
-- end
|
||||
-- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
-- 绑定快捷键
|
||||
-- require("keybindings").mapLSP(buf_set_keymap)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
return require("lsp.config.basic_config")
|
||||
|
@ -1,8 +1,14 @@
|
||||
require 'nvim-tree'.setup({
|
||||
sync_root_with_cwd = true,
|
||||
respect_buf_cwd = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_root = true
|
||||
},
|
||||
require("nvim-tree").setup({
|
||||
sync_root_with_cwd = true,
|
||||
respect_buf_cwd = true,
|
||||
-- 更改回车为进入目录
|
||||
on_attach = function(bufnr)
|
||||
local cd = require("nvim-tree.config").nvim_tree_callback("cd")
|
||||
vim.keymap.set("n", "<CR>", cd, { buffer = bufnr, noremap = true })
|
||||
end,
|
||||
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_root = true,
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user