Skip to content

Commit 49dd168

Browse files
committed
Merge branch 'main' into nvchad
2 parents 6254b82 + 81891ef commit 49dd168

File tree

16 files changed

+138
-107
lines changed

16 files changed

+138
-107
lines changed

lazy-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" },
1818
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
1919
"codecompanion-history.nvim": { "branch": "main", "commit": "811b9af74c8fd4752a3422acf2379fba0639a96c" },
20-
"codecompanion.nvim": { "branch": "main", "commit": "311219d5045fe8096bd21e0a7396855aafe7d663" },
20+
"codecompanion.nvim": { "branch": "main", "commit": "638b643a17a656a34d15c884e1fd059d0992d660" },
2121
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
2222
"copilot.lua": { "branch": "master", "commit": "0f2fd3829dd27d682e46c244cf48d9715726f612" },
2323
"crates.nvim": { "branch": "main", "commit": "fe66681d97a1eefddb5d7e48bd427b2cb0271881" },
@@ -50,7 +50,7 @@
5050
"mason.nvim": { "branch": "main", "commit": "9e25c98d4826998460926f8c5c2284848d80ae89" },
5151
"mini.align": { "branch": "main", "commit": "0202e1662a7a03a95cefd6851795ceae5e87b9b3" },
5252
"mini.cursorword": { "branch": "main", "commit": "52834085b4ad175a050343cd96c4517def711cc5" },
53-
"neoconf.nvim": { "branch": "main", "commit": "b109d170e580f85d9d41f0145cbdb1aa7caaa6fe" },
53+
"neoconf.nvim": { "branch": "main", "commit": "8d9a8e9926a9b390b2dd94b1c2b0d1307dbfe6c8" },
5454
"neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" },
5555
"none-ls.nvim": { "branch": "main", "commit": "46f2713c88a0b4e4bf134b59577659851ddd31cf" },
5656
"nvim-bqf": { "branch": "main", "commit": "17680cda3538913e88dd4c6456c837db9ace40ae" },

lua/core/global.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function global:load_variables()
1010
self.cache_dir = vim.fn.stdpath("cache")
1111
self.data_dir = string.format("%s/site/", vim.fn.stdpath("data"))
1212
self.modules_dir = self.vim_path .. "/modules"
13-
self.home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME")
13+
self.home = self.is_windows and vim.env.USERPROFILE or vim.env.HOME
1414
end
1515

1616
global:load_variables()

lua/core/options.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ local function load_options()
116116
end
117117

118118
-- Custom python provider
119-
local conda_prefix = os.getenv("CONDA_PREFIX")
119+
local conda_prefix = vim.env.CONDA_PREFIX
120120
if not isempty(conda_prefix) then
121121
vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, conda_prefix .. "/bin/python")
122122
vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, conda_prefix .. "/bin/python")
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
return function()
2-
local nvim_lsp = require("lspconfig")
32
require("completion.neoconf").setup()
43
require("completion.mason").setup()
54
require("completion.mason-lspconfig").setup()
65

76
local opts = {
87
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
98
}
10-
-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here.
9+
-- Configure LSPs that are not supported by `mason.nvim` but are available in `nvim-lspconfig`.
10+
-- First call |vim.lsp.config()|, then |vim.lsp.enable()| (or use `register_server`, see below)
11+
-- to ensure the language server is properly configured and starts automatically.
1112
if vim.fn.executable("dart") == 1 then
1213
local ok, _opts = pcall(require, "user.configs.lsp-servers.dartls")
1314
if not ok then
1415
_opts = require("completion.servers.dartls")
1516
end
1617
local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
17-
nvim_lsp.dartls.setup(final_opts)
18+
require("modules.utils").register_server("dartls", final_opts)
1819
end
1920

2021
pcall(require, "user.configs.lsp")
22+
23+
-- Start LSPs
24+
pcall(vim.cmd.LspStart)
2125
end

lua/modules/configs/completion/mason-lspconfig.lua

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
local M = {}
22

33
M.setup = function()
4+
local is_windows = require("core.global").is_windows
5+
46
local lsp_deps = require("core.settings").lsp_deps
7+
local mason_registry = require("mason-registry")
8+
local mason_lspconfig = require("mason-lspconfig")
59

610
require("lspconfig.ui.windows").default_options.border = "rounded"
711
require("modules.utils").load_plugin("mason-lspconfig", {
812
ensure_installed = lsp_deps,
13+
-- Skip auto enable because we are loading language servers lazily
14+
automatic_enable = false,
915
})
1016

1117
vim.diagnostic.config({
@@ -51,16 +57,16 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
5157

5258
if not ok then
5359
-- Default to use factory config for server(s) that doesn't include a spec
54-
vim.lsp.config(lsp_name, opts)
55-
vim.lsp.enable(lsp_name)
60+
require("modules.utils").register_server(lsp_name, opts)
5661
elseif type(custom_handler) == "function" then
57-
--- Case where language server requires its own setup
58-
--- Make sure to call require("lspconfig")[lsp_name].setup() in the function
59-
--- See `clangd.lua` for example.
62+
-- Case where language server requires its own setup
63+
-- Be sure to call `vim.lsp.config()` within the setup function.
64+
-- Refer to |vim.lsp.config()| for documentation.
65+
-- For an example, see `clangd.lua`.
6066
custom_handler(opts)
6167
vim.lsp.enable(lsp_name)
6268
elseif type(custom_handler) == "table" then
63-
vim.lsp.config(
69+
require("modules.utils").register_server(
6470
lsp_name,
6571
vim.tbl_deep_extend(
6672
"force",
@@ -69,7 +75,6 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
6975
custom_handler
7076
)
7177
)
72-
vim.lsp.enable(lsp_name)
7378
else
7479
vim.notify(
7580
string.format(
@@ -83,9 +88,98 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
8388
end
8489
end
8590

86-
for _, lsp in ipairs(lsp_deps) do
87-
mason_lsp_handler(lsp)
91+
---A simplified mimic of <mason-lspconfig 1.x>'s `setup_handlers` callback.
92+
---Invoked for each Mason package (name or `Package` object) to configure its language server.
93+
---@param pkg string|{name: string} Either the package name (string) or a Package object
94+
local function setup_lsp_for_package(pkg)
95+
-- First try to grab the builtin mappings
96+
local mappings = mason_lspconfig.get_mappings().package_to_lspconfig
97+
-- If empty or nil, build it by hand
98+
if not mappings or vim.tbl_isempty(mappings) then
99+
mappings = {}
100+
for _, spec in ipairs(mason_registry.get_all_package_specs()) do
101+
local lspconfig = vim.tbl_get(spec, "neovim", "lspconfig")
102+
if lspconfig then
103+
mappings[spec.name] = lspconfig
104+
end
105+
end
106+
end
107+
108+
-- Figure out the package name and lookup
109+
local name = type(pkg) == "string" and pkg or pkg.name
110+
local srv = mappings[name]
111+
if not srv then
112+
return
113+
end
114+
115+
-- Invoke the handler
116+
mason_lsp_handler(srv)
117+
end
118+
119+
for _, pkg in ipairs(mason_registry.get_installed_package_names()) do
120+
setup_lsp_for_package(pkg)
88121
end
122+
123+
-- Hook into Mason's package install event to install extra plugins for pylsp (black, ruff, rope),
124+
-- then configure the installed package's LSP using setup_lsp_for_package.
125+
mason_registry:on(
126+
"package:install:success",
127+
vim.schedule_wrap(function(pkg)
128+
if pkg.name == "python-lsp-server" then
129+
local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv"
130+
local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python"
131+
local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black"
132+
local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff"
133+
134+
require("plenary.job")
135+
:new({
136+
command = python,
137+
args = {
138+
"-m",
139+
"pip",
140+
"install",
141+
"-U",
142+
"--disable-pip-version-check",
143+
"python-lsp-black",
144+
"python-lsp-ruff",
145+
"pylsp-rope",
146+
},
147+
cwd = venv,
148+
env = { VIRTUAL_ENV = venv },
149+
on_exit = function()
150+
if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then
151+
vim.notify(
152+
"Finished installing pylsp plugins",
153+
vim.log.levels.INFO,
154+
{ title = "[lsp] Install Status" }
155+
)
156+
else
157+
vim.notify(
158+
"Failed to install pylsp plugins. [Executable not found]",
159+
vim.log.levels.ERROR,
160+
{ title = "[lsp] Install Failure" }
161+
)
162+
end
163+
end,
164+
on_start = function()
165+
vim.notify(
166+
"Now installing pylsp plugins...",
167+
vim.log.levels.INFO,
168+
{ title = "[lsp] Install Status", timeout = 6000 }
169+
)
170+
end,
171+
on_stderr = function(_, msg_stream)
172+
if msg_stream then
173+
vim.notify(msg_stream, vim.log.levels.ERROR, { title = "[lsp] Install Failure" })
174+
end
175+
end,
176+
})
177+
:start()
178+
end
179+
180+
setup_lsp_for_package(pkg)
181+
end)
182+
)
89183
end
90184

91185
return M
Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
local M = {}
22

33
M.setup = function()
4-
local is_windows = require("core.global").is_windows
5-
6-
local mason_registry = require("mason-registry")
7-
require("lspconfig.ui.windows").default_options.border = "rounded"
8-
94
local icons = {
105
ui = require("modules.utils.icons").get("ui", true),
116
misc = require("modules.utils.icons").get("misc", true),
@@ -31,66 +26,6 @@ M.setup = function()
3126
},
3227
},
3328
})
34-
35-
-- Additional plugins for pylsp
36-
mason_registry:on(
37-
"package:install:success",
38-
vim.schedule_wrap(function(pkg)
39-
if pkg.name ~= "python-lsp-server" then
40-
return
41-
end
42-
43-
local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv"
44-
local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python"
45-
local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black"
46-
local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff"
47-
48-
require("plenary.job")
49-
:new({
50-
command = python,
51-
args = {
52-
"-m",
53-
"pip",
54-
"install",
55-
"-U",
56-
"--disable-pip-version-check",
57-
"python-lsp-black",
58-
"python-lsp-ruff",
59-
"pylsp-rope",
60-
},
61-
cwd = venv,
62-
env = { VIRTUAL_ENV = venv },
63-
on_exit = function()
64-
if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then
65-
vim.notify(
66-
"Finished installing pylsp plugins",
67-
vim.log.levels.INFO,
68-
{ title = "[lsp] Install Status" }
69-
)
70-
else
71-
vim.notify(
72-
"Failed to install pylsp plugins. [Executable not found]",
73-
vim.log.levels.ERROR,
74-
{ title = "[lsp] Install Failure" }
75-
)
76-
end
77-
end,
78-
on_start = function()
79-
vim.notify(
80-
"Now installing pylsp plugins...",
81-
vim.log.levels.INFO,
82-
{ title = "[lsp] Install Status", timeout = 6000 }
83-
)
84-
end,
85-
on_stderr = function(_, msg_stream)
86-
if msg_stream then
87-
vim.notify(msg_stream, vim.log.levels.ERROR, { title = "[lsp] Install Failure" })
88-
end
89-
end,
90-
})
91-
:start()
92-
end)
93-
)
9429
end
9530

9631
return M

lua/modules/configs/completion/servers/clangd.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ end
3535

3636
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/clangd.lua
3737
return function(defaults)
38-
require("lspconfig").clangd.setup({
38+
vim.lsp.config("clangd", {
3939
on_attach = defaults.on_attach,
4040
capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, defaults.capabilities),
4141
single_file_support = true,

lua/modules/configs/editor/persisted.lua

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
return function()
2-
vim.api.nvim_create_autocmd("User", {
3-
pattern = "PersistedLoadPost",
4-
desc = "Fix LSP/Highlighting on auto session restore",
5-
callback = function()
6-
local bufname = vim.api.nvim_buf_get_name(0)
7-
if bufname and bufname ~= "" then
8-
vim.defer_fn(function()
9-
vim.cmd("edit")
10-
end, 1)
11-
end
12-
end,
13-
})
142
require("modules.utils").load_plugin("persisted", {
153
save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"),
164
autostart = true,

lua/modules/configs/lang/render-markdown.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ return function()
1414
-- This enables hiding any added text on the line the cursor is on
1515
-- This does have a performance penalty as we must listen to the 'CursorMoved' event
1616
anti_conceal = { enabled = true },
17-
-- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log'
17+
-- The level of logs to write to file: vim.fn.stdpath("state") .. "/render-markdown.log"
1818
-- Only intended to be used for plugin development / debugging
1919
log_level = "error",
2020
})

lua/modules/configs/tool/dap/clients/delve.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ return function()
2424

2525
dap.adapters.go = {
2626
type = "executable",
27-
command = "node",
28-
args = {
29-
vim.fn.expand("$MASON") .. "/packages/go-debug-adapter" .. "/extension/dist/debugAdapter.js",
30-
},
27+
command = vim.fn.exepath("go-debug-adapter"), -- Find go-debug-adapter on $PATH
3128
}
3229
dap.configurations.go = {
3330
{

0 commit comments

Comments
 (0)