This commit is contained in:
2026-10-06 12:49:41 +03:00
parent 3fe6ca3d6b
commit a87e5ea4f5
6 changed files with 164 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
return {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
gopls = {
settings = {
gopls = {
buildFlags = { "-tags=unit,integration" },
},
},
},
},
setup = {
-- Override LazyVim's gopls semanticTokens workaround, which crashes on
-- Neovim 0.12 because the gopls client's config.capabilities has no
-- `textDocument` field (go.lua:60). Guard against the nil.
gopls = function(_, _)
Snacks.util.lsp.on({ name = "gopls" }, function(_, client)
if client.server_capabilities.semanticTokensProvider then
return
end
local caps = client.config.capabilities or {}
local semantic = caps.textDocument and caps.textDocument.semanticTokens
if not semantic then
return
end
client.server_capabilities.semanticTokensProvider = {
full = true,
legend = {
tokenTypes = semantic.tokenTypes,
tokenModifiers = semantic.tokenModifiers,
},
range = true,
}
end)
end,
},
},
},
}
+77
View File
@@ -0,0 +1,77 @@
-- Custom project picker: selecting a project changes the working directory
-- and restores that project's last session (open buffers/windows) via
-- persistence.nvim. It does NOT open a file search afterwards (the default
-- LazyVim `util.project` behaviour opens `find_files` on select).
local function pick_project_cd()
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local state = require("telescope.actions.state")
local history = require("project_nvim.utils.history")
local project = require("project_nvim.project")
local results = history.get_recent_projects()
-- Show most recent projects first.
for i = 1, math.floor(#results / 2) do
results[i], results[#results - i + 1] = results[#results - i + 1], results[i]
end
pickers
.new({}, {
prompt_title = "Recent Projects (cd only)",
finder = finders.new_table({
results = results,
entry_maker = function(entry)
local name = vim.fn.fnamemodify(entry, ":t")
return {
value = entry,
display = string.format("%-30s %s", name, entry),
ordinal = name .. " " .. entry,
}
end,
}),
previewer = false,
sorter = conf.generic_sorter({}),
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local entry = state.get_selected_entry()
actions.close(prompt_bufnr)
if not entry then
return
end
if project.set_pwd(entry.value, "telescope") then
vim.notify("Changed project dir to " .. entry.value)
-- Restore the last session (open buffers/windows) for this dir.
local ok, persistence = pcall(require, "persistence")
if ok then
persistence.load()
end
end
end)
return true
end,
})
:find()
end
return {
-- This overrides the repository source for the built-in LazyVim extra
{
"ahmedkhalf/project.nvim",
name = "project_nvim", -- Keeps internal naming intact
url = "https://github.com/DrKJeff16/project.nvim", -- Directs lazy.nvim to download the fork
opts = {
manual_mode = false, -- Prevents root changing unexpectedly on every single file open
},
},
-- Override <leader>fp so it only cd's into the project.
{
"nvim-telescope/telescope.nvim",
optional = true,
keys = {
{ "<leader>fp", pick_project_cd, desc = "Projects (cd only)" },
},
},
}
+28
View File
@@ -0,0 +1,28 @@
return {
-- The newer refactoring.nvim (Neovim 0.12+) replaced its plenary dependency
-- with lewis6991/async.nvim. The LazyVim extra doesn't declare it yet, so add
-- it here to fix `module 'async' not found`.
--
-- It also removed the bundled Telescope extension (`telescope._extensions.refactoring`),
-- so we override the extra's `config` and `<leader>rs` keymap to use the
-- built-in `select_refactor()` (vim.ui.select) instead of the missing extension.
{
"ThePrimeagen/refactoring.nvim",
dependencies = {
"lewis6991/async.nvim",
},
config = function(_, opts)
require("refactoring").setup(opts)
end,
keys = {
{
"<leader>rs",
function()
require("refactoring").select_refactor()
end,
mode = { "n", "x" },
desc = "Refactor",
},
},
},
}