Skip to content

Commit 713ca7a

Browse files
committed
打磨
1 parent d6154ca commit 713ca7a

File tree

14 files changed

+136
-110
lines changed

14 files changed

+136
-110
lines changed

ftplugin/bash.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vim.bo.shiftwidth = 4
2+
vim.bo.tabstop = 4
3+
vim.bo.softtabstop = 4

ftplugin/c.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
vim.bo.shiftwidth = 4
2+
vim.bo.tabstop = 4
3+
vim.bo.softtabstop = 4
14
vim.lsp.start(require("kide.lsp.clangd").config)

ftplugin/css.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vim.lsp.start(require("kide.lsp.cssls").config)

ftplugin/java.lua

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ vim.bo.tabstop = 4
33
vim.bo.softtabstop = 4
44

55
if vim.env["JDTLS_NVIM_ENABLE"] == "Y" then
6-
require("jdtls").start_or_attach(
7-
require("kide.lsp.java").config,
8-
{ dap = { config_overrides = {}, hotcodereplace = "auto" } }
9-
)
10-
vim.lsp.start(require("kide.lsp.spring-boot").config)
6+
local jc = require("kide.lsp.java")
7+
local config
8+
-- 防止 start_or_attach 重复修复 config
9+
if jc.init then
10+
config = {
11+
cmd = {},
12+
}
13+
else
14+
config = jc.config
15+
jc.init = true
16+
end
17+
require("jdtls").start_or_attach(config, { dap = { config_overrides = {}, hotcodereplace = "auto" } })
1118
end
19+
20+
require("spring_boot.launch").start(require("kide.lsp.spring-boot").config)

ftplugin/sh.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vim.bo.shiftwidth = 4
2+
vim.bo.tabstop = 4
3+
vim.bo.softtabstop = 4

lua/kide/lsp/cssls.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
local M = {}
2+
3+
local me = require("kide.melspconfig")
4+
M.config = {
5+
name = "cssls",
6+
cmd = { "vscode-css-language-server", "--stdio" },
7+
filetypes = { "css", "scss", "less" },
8+
init_options = { provideFormatter = true },
9+
root_dir = vim.fs.root(0, { "package.json" }),
10+
single_file_support = true,
11+
settings = {
12+
css = { validate = true },
13+
scss = { validate = true },
14+
less = { validate = true },
15+
},
16+
on_attach = me.on_attach,
17+
on_init = me.on_init,
18+
capabilities = me.capabilities(),
19+
}
20+
21+
return M

lua/kide/lsp/html.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ M.config = {
77
filetypes = { "html", "templ" },
88
root_dir = vim.fs.root(0, { "package.json", ".git" }) or vim.uv.cwd(),
99
single_file_support = true,
10-
settings = {
11-
html = {},
12-
},
10+
settings = {},
1311
init_options = {
1412
provideFormatter = true,
1513
embeddedLanguages = { css = true, javascript = true },

lua/kide/lsp/jsonls.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ M.config = {
88
init_options = {
99
provideFormatter = true,
1010
},
11-
root_dir = vim.fs.root(0, { ".git" }) or vim.uv.cwd(),
11+
root_dir = vim.fs.root(0, { ".git" }),
1212
single_file_support = true,
1313
on_attach = me.on_attach,
1414
on_init = me.on_init,
1515
capabilities = me.capabilities(),
16-
settings = {
17-
jsonls = {},
18-
},
16+
settings = {},
1917
}
2018
return M

lua/kide/lsp/pyright.lua

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ function M.init_dap()
2222
end
2323

2424
local me = require("kide.melspconfig")
25+
26+
-- see nvim-lspconfig
27+
function M.organize_imports()
28+
local params = {
29+
command = "pyright.organizeimports",
30+
arguments = { vim.uri_from_bufnr(0) },
31+
}
32+
33+
local clients = vim.lsp.get_clients({
34+
bufnr = vim.api.nvim_get_current_buf(),
35+
name = "pyright",
36+
})
37+
for _, client in ipairs(clients) do
38+
client:request("workspace/executeCommand", params, nil, 0)
39+
end
40+
end
41+
2542
M.config = {
2643
name = "pyright",
2744
cmd = { "pyright-langserver", "--stdio" },
@@ -31,12 +48,24 @@ M.config = {
3148
vim.keymap.set("n", "<leader>dc", dap_py.test_class, { desc = "Dap Test Class", buffer = bufnr })
3249
vim.keymap.set("n", "<leader>dm", dap_py.test_method, { desc = "Dap Test Method", buffer = bufnr })
3350
vim.keymap.set("v", "<leader>ds", dap_py.debug_selection, { desc = "Dap Debug Selection", buffer = bufnr })
51+
52+
local create_command = vim.api.nvim_buf_create_user_command
53+
create_command(bufnr, "OR", M.organize_imports, {
54+
nargs = 0,
55+
})
3456
me.on_attach(client, bufnr)
3557
end,
3658
on_init = me.on_init,
3759
capabilities = me.capabilities(),
3860
settings = {
39-
pyright = {},
61+
python = {
62+
analysis = {
63+
autoSearchPaths = true,
64+
useLibraryCodeForTypes = true,
65+
diagnosticMode = "openFilesOnly",
66+
},
67+
},
4068
},
4169
}
70+
4271
return M

lua/kide/melspconfig.lua

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,11 @@ M.on_init = function(client, _)
5050
end
5151
M.capabilities = function(opt)
5252
local capabilities = vim.lsp.protocol.make_client_capabilities()
53-
capabilities.textDocument.completion.completionItem = {
54-
documentationFormat = { "markdown", "plaintext" },
55-
snippetSupport = true,
56-
preselectSupport = true,
57-
insertReplaceSupport = true,
58-
labelDetailsSupport = true,
59-
deprecatedSupport = true,
60-
commitCharactersSupport = true,
61-
tagSupport = { valueSet = { 1 } },
62-
resolveSupport = {
63-
properties = {
64-
"documentation",
65-
"detail",
66-
"additionalTextEdits",
67-
},
68-
},
69-
}
7053
if opt then
7154
capabilities = vim.tbl_deep_extend("force", capabilities, opt)
7255
end
7356

74-
capabilities = require("blink.cmp").get_lsp_capabilities(capabilities)
75-
if capabilities.textDocument.foldingRange then
76-
capabilities.textDocument.foldingRange.dynamicRegistration = false
77-
capabilities.textDocument.foldingRange.lineFoldingOnly = true
78-
else
79-
capabilities.textDocument.foldingRange = {
80-
dynamicRegistration = false,
81-
lineFoldingOnly = true,
82-
}
83-
end
84-
return capabilities
57+
return require("blink.cmp").get_lsp_capabilities(capabilities)
8558
end
8659

8760
M.init_lsp_progress = function()
@@ -90,7 +63,7 @@ end
9063

9164
function M.global_node_modules()
9265
local global_path = ""
93-
if vfn.isdirectory("/opt/homebrew/") == 1 then
66+
if vfn.isdirectory("/opt/homebrew/lib/node_modules") == 1 then
9467
global_path = "/opt/homebrew/lib/node_modules"
9568
elseif vfn.isdirectory("/usr/local/lib/node_modules") == 1 then
9669
global_path = "/usr/local/lib/node_modules"

0 commit comments

Comments
 (0)