make lsp some changes and a easy new file

This commit is contained in:
gameloader 2022-10-20 10:30:00 +08:00
parent e1ecbd9818
commit 1941ccef40
8 changed files with 111 additions and 37 deletions

View File

@ -31,5 +31,6 @@ require("plugin-config/lazygit")
require("lsp")
require("lsp.cmp")
require("lsp.null-ls")
require("lsp.ui")
require("nvim-dap")

View File

@ -49,7 +49,7 @@ wk.register({
p = { ":Telescope projects<CR>", "Open project" },
r = { ":Telescope oldfiles<CR>", "Recent files" },
f = { ":Telescope file_browser<CR>", "File browser" },
n = { ":enew<CR>", "New file" },
n = { ":AdvancedNewFile<CR>", "New file" },
s = { ":Telescope live_grep<CR>", "Search in project" },
},
})

View File

@ -1,21 +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
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
-- 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,
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,
}

View File

@ -9,6 +9,20 @@ return {
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

View File

@ -35,6 +35,20 @@ local opts = {
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,

View File

@ -1,21 +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
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
-- 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,
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,
}

13
lua/lsp/ui.lua Normal file
View File

@ -0,0 +1,13 @@
vim.diagnostic.config({
virtual_text = false,
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
})
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end

View File

@ -98,6 +98,10 @@ return require("packer").startup(function()
-- telescope-file-browser
use({ "nvim-telescope/telescope-file-browser.nvim" })
-- create new file
-- 快捷创建新文件
use("Mohammed-Taher/AdvancedNewFile.nvim")
-- project
-- 项目管理
use({