From 519f262227154b8c409735514dd4e235f9fe9740 Mon Sep 17 00:00:00 2001 From: "Mariano Z." Date: Mon, 23 Dec 2024 14:21:17 -0300 Subject: [PATCH] chore: use mini modules instead of the whole repo --- lazy-lock.json | 15 ++++++----- lua/plugins/format.lua | 2 ++ lua/plugins/lsp/init.lua | 27 ++++++++++++++++---- lua/plugins/mini.lua | 54 +++++++++++++++++++++++---------------- lua/plugins/ui/colors.lua | 2 ++ 5 files changed, 67 insertions(+), 33 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 44c02f3..10fd078 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -9,10 +9,10 @@ "codeium.vim": { "branch": "main", "commit": "d152e6cd3d814a44f36447bb0d21d51f6787fe9c" }, "conform.nvim": { "branch": "master", "commit": "339b3e4519ec49312d34fcfa275aa15bfaa67025" }, "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, - "ecolog.nvim": { "branch": "main", "commit": "3bac03f21c8a99af2b2b33199205a2e7bacf2012" }, + "ecolog.nvim": { "branch": "main", "commit": "b1318b6b017ea2d211206fc666d3b051dece4e6a" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "fzf-lua": { "branch": "main", "commit": "c3cfa2b59ad1903f79a5a431ce3133300dd6e072" }, + "fzf-lua": { "branch": "main", "commit": "7022b5b002bb7488e1be4470bad2342bcc8d4d99" }, "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, "gopher.nvim": { "branch": "main", "commit": "f55c15ada8e02398000c04a96ef44d986cd01051" }, @@ -24,7 +24,10 @@ "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "2daa8921b7afdcfa47419a21ea343c3df6d74fa0" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "4228f166ee9db3e910eea1915e2d3683028add47" }, + "mini.ai": { "branch": "main", "commit": "ebb04799794a7f94628153991e6334c3304961b8" }, + "mini.icons": { "branch": "main", "commit": "44c0160526f7ae17ca8e8eab9ab235d047fcf7a6" }, + "mini.nvim": { "branch": "main", "commit": "2011aff270bcd3e1f3ad088253ace2d574967bed" }, + "mini.surround": { "branch": "main", "commit": "aa5e245829dd12d8ff0c96ef11da28681d6049aa" }, "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, "nightfox.nvim": { "branch": "main", "commit": "7557f26defd093c4e9bc17f28b08403f706f5a44" }, "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, @@ -32,10 +35,10 @@ "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, "nvim-lint": { "branch": "master", "commit": "1fea92f1d9908eaa5eb8bafe08b4293d7aadaa55" }, - "nvim-lspconfig": { "branch": "master", "commit": "9204642002ba91f9e0b7d0e5989f373657fe754a" }, + "nvim-lspconfig": { "branch": "master", "commit": "c580f34bc5fdca8aaf737a9ab8a5d775cb940e57" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-spectre": { "branch": "master", "commit": "08be31c104df3b4b049607694ebb2b6ced4f928b" }, - "nvim-treesitter": { "branch": "master", "commit": "caba7ef3556079dec03407bcbb290ddc688ea06e" }, + "nvim-treesitter": { "branch": "master", "commit": "b4897f5a8453e7efeafb21ff5b2bbdc2e3faf1bd" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-vtsls": { "branch": "main", "commit": "45c6dfea9f83a126e9bfc5dd63430562b3f8af16" }, "oil.nvim": { "branch": "master", "commit": "ba858b662599eab8ef1cba9ab745afded99cb180" }, @@ -43,7 +46,7 @@ "pretty-fold.nvim": { "branch": "master", "commit": "1eb18f228972e86b7b8f5ef33ca8091e53fb1e49" }, "render-markdown.nvim": { "branch": "main", "commit": "0022a579ac7355966be5ade77699b88c76b6a549" }, "rose-pine": { "branch": "main", "commit": "91548dca53b36dbb9d36c10f114385f759731be1" }, - "schemastore.nvim": { "branch": "main", "commit": "af3f82cd4972520e6ac04c48ed3eed473660efca" }, + "schemastore.nvim": { "branch": "main", "commit": "e6085187d6c5bde220ebbf38c963a2fda77dfbb4" }, "suda.vim": { "branch": "master", "commit": "9adda7d195222d4e2854efb2a88005a120296c47" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, diff --git a/lua/plugins/format.lua b/lua/plugins/format.lua index 13f8258..d3ebcf8 100644 --- a/lua/plugins/format.lua +++ b/lua/plugins/format.lua @@ -20,6 +20,8 @@ return { go = { "gofumpt", "goimports-reviser", "golines" }, cs = { "csharpier" }, templ = { "templ" }, + c = { "clang-format" }, + cpp = { "clang-format" }, }, formatters = { csharpier = { diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua index 6d568cf..f148b9d 100644 --- a/lua/plugins/lsp/init.lua +++ b/lua/plugins/lsp/init.lua @@ -10,6 +10,7 @@ local M = { }, } +-- Set up autocommands for document highlights local function setup_autocommands(client, bufnr) if client.server_capabilities.documentHighlightProvider then local group = vim.api.nvim_create_augroup("LSPDocumentHighlight", { clear = true }) @@ -26,6 +27,7 @@ local function setup_autocommands(client, bufnr) end end +-- Set up key mappings for LSP functionality local function setup_keymaps(bufnr) local keymaps = { { "", vim.lsp.buf.signature_help, "Signature Help" }, @@ -44,6 +46,7 @@ local function setup_keymaps(bufnr) end end +-- Function called when LSP attaches to a buffer local function on_attach(client, bufnr) setup_autocommands(client, bufnr) setup_keymaps(bufnr) @@ -51,12 +54,14 @@ end local BORDER = "rounded" +-- Customize hover and signature help handlers local handlers = { ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = BORDER }), ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = BORDER }), } function M.config() + -- Set up Mason require("mason").setup({ max_concurrent_installers = 4, }) @@ -79,12 +84,14 @@ function M.config() "shfmt", "stylua", "latexindent", + "clang-format", -- Additional tools "eslint_d", "templ", } + -- Install missing tools local registry = require("mason-registry") for _, tool in ipairs(ensure_installed) do if not registry.is_installed(tool) then @@ -92,6 +99,7 @@ function M.config() end end + -- Set up Mason LSP config require("mason-lspconfig").setup({ automatic_installation = true, ensure_installed = { @@ -118,22 +126,31 @@ function M.config() on_attach = on_attach, capabilities = capabilities, handlers = handlers, - flags = { - debounce_text_changes = 150, - }, + flags = { debounce_text_changes = 150 }, } - -- Try to load server-specific configuration + -- Load server-specific configuration if it exists local ok, server_opts = pcall(require, "plugins.lsp.servers." .. server_name) if ok then base_opts = vim.tbl_deep_extend("force", base_opts, server_opts) end - -- Set up the LSP server + -- Set up the LSP server with the combined options require("lspconfig")[server_name].setup(base_opts) end, }, }) + + -- Set up non-Mason LSP servers + local non_mason_servers = { "ccls" } + for _, server in ipairs(non_mason_servers) do + require("lspconfig")[server].setup({ + on_attach = on_attach, + capabilities = require("blink.cmp").get_lsp_capabilities(), + handlers = handlers, + flags = { debounce_text_changes = 150 }, + }) + end end return M diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 3781553..899c732 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -1,24 +1,34 @@ -return { - "echasnovski/mini.nvim", - config = function() - require("mini.icons").setup() +local M = { - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - require("mini.ai").setup({ n_lines = 500 }) - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require("mini.surround").setup({}) - end, - init = function() - package.preload["nvim-web-devicons"] = function() - require("mini.icons").mock_nvim_web_devicons() - return package.loaded["nvim-web-devicons"] - end - end, + { + "echasnovski/mini.icons", + init = function() + package.preload["nvim-web-devicons"] = function() + require("mini.icons").mock_nvim_web_devicons() + return package.loaded["nvim-web-devicons"] + end + end, + }, + { + "echasnovski/mini.ai", + config = function() + -- - va) - [V]isually select [A]round [)]paren + -- - yinq - [Y]ank [I]nside [N]ext [Q]uote + -- - ci' - [C]hange [I]nside [']quote + require("mini.ai").setup({ n_lines = 500 }) + end, + }, + { + "echasnovski/mini.surround", + config = function() + -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- + -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - sd' - [S]urround [D]elete [']quotes + -- - sr)' - [S]urround [R]eplace [)] ['] + require("mini.surround").setup({}) + end, + }, } + +return M diff --git a/lua/plugins/ui/colors.lua b/lua/plugins/ui/colors.lua index c6d991a..333b90d 100644 --- a/lua/plugins/ui/colors.lua +++ b/lua/plugins/ui/colors.lua @@ -5,6 +5,8 @@ local M = { priority = 1000, config = function() vim.cmd("colorscheme nightfox") + vim.api.nvim_set_hl(0, "Visual", { bg = "#1f4b6d", fg = "#ffffff" }) + vim.api.nvim_set_hl(0, "VisualNOS", { bg = "#1f4b6d", fg = "#ffffff" }) end, }, {