diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 02f3726..ab5925a 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -9,6 +9,9 @@ return { explorer = { replace_netrw = true, }, + lazygit = { + enabled = true, + }, picker = { sources = { explorer = { @@ -36,9 +39,13 @@ return { }, keys = { -- Ctrl+Shift+e - Toggle explorer - { "", function() Snacks.explorer() end, desc = "Toggle Explorer" }, + { "", function() Snacks.explorer() end, desc = "Toggle Explorer" }, -- Alternative binding if terminal doesn't handle Ctrl+Shift - { "fe", function() Snacks.explorer() end, desc = "File Explorer" }, + { "fe", function() Snacks.explorer() end, desc = "File Explorer" }, + -- Lazygit + { "gg", function() Snacks.lazygit() end, desc = "Lazygit" }, + { "gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log" }, + { "gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit File History" }, }, }, @@ -49,6 +56,7 @@ return { spec = { { "a", group = "AI" }, { "d", group = "Debug/Database" }, + { "g", group = "Git" }, { "t", group = "Terminal" }, }, }, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 8aee44b..79aeefb 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,6 +1,21 @@ -- LSP Configuration -- Extends LazyVim's built-in LSP support +-- Helper function for monorepo root detection +-- Finds nearest project marker, with fallback to git root +local function make_root_detector(markers) + return function(fname) + local util = require("lspconfig.util") + -- First try language-specific markers (nearest to file) + local root = util.root_pattern(unpack(markers))(fname) + if root then + return root + end + -- Fallback to git root + return util.root_pattern(".git")(fname) + end +end + return { -- Mason: manage LSP servers, linters, formatters { @@ -40,6 +55,8 @@ return { servers = { -- Go gopls = { + -- Root detection: find go.work first, then go.mod, then git root + root_dir = make_root_detector({ "go.work", "go.mod" }), settings = { gopls = { gofumpt = true, @@ -74,12 +91,19 @@ return { staticcheck = true, directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, semanticTokens = true, + -- Monorepo/workspace support + expandWorkspaceToModule = true, + experimentalPostfixCompletions = true, + -- Handle multiple modules + ["build.standaloneTags"] = { "ignore" }, }, }, }, -- Lua lua_ls = { + root_dir = make_root_detector({ ".luarc.json", ".luarc.jsonc", ".luacheckrc", ".stylua.toml", "stylua.toml", + "selene.toml", "selene.yml" }), settings = { Lua = { workspace = { @@ -97,6 +121,8 @@ return { -- TypeScript/JavaScript ts_ls = { + -- Root detection: find nearest tsconfig/package.json + root_dir = make_root_detector({ "tsconfig.json", "jsconfig.json", "package.json" }), settings = { typescript = { inlayHints = { @@ -125,17 +151,23 @@ return { -- HTML html = { + root_dir = make_root_detector({ "package.json", ".git" }), filetypes = { "html", "templ" }, }, -- CSS - cssls = {}, + cssls = { + root_dir = make_root_detector({ "package.json", ".git" }), + }, -- JSON - jsonls = {}, + jsonls = { + root_dir = make_root_detector({ "package.json", ".git" }), + }, -- YAML yamlls = { + root_dir = make_root_detector({ "package.json", ".git" }), settings = { yaml = { keyOrdering = false, @@ -148,10 +180,14 @@ return { }, -- Markdown - marksman = {}, + marksman = { + root_dir = make_root_detector({ ".marksman.toml", ".git" }), + }, -- SQL - sqlls = {}, + sqlls = { + root_dir = make_root_detector({ ".sqllsrc.json", "sqlls.json", ".git" }), + }, }, }, },