Prechádzať zdrojové kódy

chore: remove ecolog, i don't use it

Mariano Z. 10 mesiacov pred
rodič
commit
1020911f18

+ 14 - 0
.githooks/pre-commit

@@ -0,0 +1,14 @@
+#!/bin/bash
+STYLUA_PATH="$HOME/.local/share/nvim/mason/bin/stylua"
+
+if [[ -x "$STYLUA_PATH" ]]; then
+  LUA_FILES=$(git diff --cached --name-only --diff-filter=AM | grep '\.lua$')
+
+  if [ -n "$LUA_FILES" ]; then
+    echo "$LUA_FILES" | xargs "$STYLUA_PATH"
+    echo "$LUA_FILES" | xargs git add
+  fi
+else
+  echo "Error: stylua not found. Please install it via Mason."
+  exit 1
+fi

+ 23 - 2
README.md

@@ -5,12 +5,33 @@ This is my personal Neovim setup, tailored for a fast and minimal development wo
 ## Installation
 
 1. Clone the repo:
+
    ```bash
    git clone https://github.com/marianozunino/nvim.git ~/.config/nvim
    ```
-2. Open Neovim
-![Neovim Setup](pic.jpg)
 
+2. Set up Git hooks (optional but recommended):
+   If you'd like to automatically format Lua files before committing, configure Git to use the custom `.githooks` directory:
+
+   ```bash
+   git config core.hooksPath .githooks
+   ```
+
+3. Make sure that `stylua` is installed via Mason:
+
+   ```bash
+   :MasonInstall stylua
+   ```
+
+   This configuration relies on `stylua` being installed by Mason at `~/.local/share/nvim/mason/bin/stylua`.
+
+4. Open Neovim:
+
+   ```bash
+   nvim
+   ```
+
+   ![Neovim Setup](pic.jpg)
 
 ## License
 

+ 5 - 12
lazy-lock.json

@@ -2,19 +2,18 @@
   "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
   "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
   "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" },
-  "blink.cmp": { "branch": "main", "commit": "4607923f60029f8cb28e6950a078f93fd33e1288" },
+  "blink.cmp": { "branch": "main", "commit": "485c03400608cb6534bbf84da8c1c471fc4808c0" },
   "chezmoi.nvim": { "branch": "main", "commit": "3f72cffa2d18aaec884502443bae37226f3decd2" },
   "chezmoi.vim": { "branch": "main", "commit": "abf37336437867cbd99ce2f8849b717415391cc3" },
   "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" },
   "conform.nvim": { "branch": "master", "commit": "f9ef25a7ef00267b7d13bfc00b0dea22d78702d5" },
   "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
-  "ecolog.nvim": { "branch": "main", "commit": "fec56a2d15fe7220b30f6d24fdfb26397105c567" },
   "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
   "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
   "fzf-lua": { "branch": "main", "commit": "ac6a34ea39831ec71c14f72075facf377ea9a00d" },
   "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
   "gitsigns.nvim": { "branch": "main", "commit": "7010000889bfb6c26065e0b0f7f1e6aa9163edd9" },
-  "go.nvim": { "branch": "master", "commit": "f058a8c622edf24d27b8ef82fabffdbbc1d55707" },
+  "go.nvim": { "branch": "master", "commit": "dfebd810ef38805c71a00a22a19c8bd8afcfcf25" },
   "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
   "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
   "knap": { "branch": "main", "commit": "7db44d0bb760120142cc1e8f43e44976de59c2f6" },
@@ -24,7 +23,6 @@
   "lualine.nvim": { "branch": "master", "commit": "9fef261b53fbe3a2ef01ee9667f6fde064b1ed10" },
   "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
   "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
-  "mason-nvim-dap.nvim": { "branch": "main", "commit": "444aad7977ee713a4049e9d1dd9b377967d67a4c" },
   "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
   "mini.ai": { "branch": "main", "commit": "978ffc65c6b513fde9ef075326d34d89197f1ea5" },
   "mini.icons": { "branch": "main", "commit": "ec61af6e606fc89ee3b1d8f2f20166a3ca917a36" },
@@ -35,26 +33,21 @@
   "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
   "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" },
   "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
-  "nvim-dap": { "branch": "master", "commit": "6a5bba0ddea5d419a783e170c20988046376090d" },
-  "nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
-  "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" },
   "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
   "nvim-lint": { "branch": "master", "commit": "936197073214c26a347fb933c9459c8766376b23" },
   "nvim-lspconfig": { "branch": "master", "commit": "fb733ac734249ccf293e5c8018981d4d8f59fa8f" },
-  "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
   "nvim-spectre": { "branch": "master", "commit": "ddd7383e856a7c939cb4f5143278fe041bbb8cb9" },
-  "nvim-treesitter": { "branch": "master", "commit": "d26ce0126694283cf32bf1f4192ef37ef404c037" },
+  "nvim-treesitter": { "branch": "master", "commit": "e329e94a6a0a5ccf6ec8bfec1d10faf5eaae665f" },
   "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },
-  "nvim-vtsls": { "branch": "main", "commit": "45c6dfea9f83a126e9bfc5dd63430562b3f8af16" },
   "oil.nvim": { "branch": "master", "commit": "ab887d926c2665a708fbe9e6c4654042cc5f4c60" },
   "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
   "pretty-fold.nvim": { "branch": "master", "commit": "1eb18f228972e86b7b8f5ef33ca8091e53fb1e49" },
   "render-markdown.nvim": { "branch": "main", "commit": "d6aaa19913415c653fa38aead4d9867628394510" },
-  "schemastore.nvim": { "branch": "main", "commit": "f293a809fc93e972fcc71fde473f55606cadb091" },
+  "schemastore.nvim": { "branch": "main", "commit": "236438da47cafc39b15d2017a229a6613c581055" },
   "suda.vim": { "branch": "master", "commit": "9adda7d195222d4e2854efb2a88005a120296c47" },
   "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
   "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
-  "ts-error-translator.nvim": { "branch": "main", "commit": "47e5ba89f71b9e6c72eaaaaa519dd59bd6897df4" },
+  "typescript-tools.nvim": { "branch": "master", "commit": "35e397ce467bedbbbb5bfcd0aa79727b59a08d4a" },
   "undotree": { "branch": "master", "commit": "b951b87b46c34356d44aa71886aecf9dd7f5788a" },
   "vim-dadbod": { "branch": "master", "commit": "9f0ca8bcef704659820a95c3bbd2c262583a66a1" },
   "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" },

+ 7 - 2
lua/plugins/diagnostics.lua

@@ -5,8 +5,13 @@ local M = {
 
 local function setup_keymaps(trouble)
   -- Diagnostic navigation
-  nmap("[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" })
-  nmap("]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
+  nmap("[d", function()
+    vim.diagnostic.jump({ count = -1, float = true })
+  end, { desc = "Previous diagnostic" })
+
+  nmap("]d", function()
+    vim.diagnostic.jump({ count = 1, float = true })
+  end, { desc = "Next diagnostic" })
 
   -- Trouble specific navigation
   nmap("<a-k>", function()

+ 16 - 51
lua/plugins/env.lua

@@ -1,59 +1,24 @@
 local M = {
-  {
-    "laytan/cloak.nvim",
-    config = function()
-      require("cloak").setup({
-        cloak_character = "*",
-        highlight_group = "Comment",
-        patterns = {
-          {
-            file_pattern = {
-              ".env*",
-              "wrangler.toml",
-              ".dev.vars",
-            },
-            cloak_pattern = "=.+",
-          },
-        },
-      })
+  "laytan/cloak.nvim",
+}
 
-      nmap("<Leader>cc", ":CloakToggle<cr>")
-    end,
-  },
-  {
-    "philosofonusus/ecolog.nvim",
-    keys = {
-      { "<leader>ge", "<cmd>EcologGoto<cr>", desc = "Go to env file" },
-      { "<leader>ep", "<cmd>EcologPeek<cr>", desc = "Ecolog peek variable" },
-      { "<leader>es", "<cmd>EcologSelect<cr>", desc = "Switch env file" },
-    },
-    -- Lazy loading is done internally
-    lazy = false,
-    opts = {
-      integrations = {
-        blink_cmp = true,
-      },
-      -- Enables shelter mode for sensitive values
-      shelter = {
-        configuration = {
-          partial_mode = false, -- false by default, disables partial mode, for more control check out shelter partial mode
-          mask_char = "*", -- Character used for masking
-        },
-        modules = {
-          cmp = true, -- Mask values in completion
-          peek = false, -- Mask values in peek view
-          files = false, -- Mask values in files
-          telescope = false, -- Mask values in telescope
+M.config = function()
+  require("cloak").setup({
+    cloak_character = "*",
+    highlight_group = "Comment",
+    patterns = {
+      {
+        file_pattern = {
+          ".env*",
+          "wrangler.toml",
+          ".dev.vars",
         },
+        cloak_pattern = "=.+",
       },
-      -- true by default, enables built-in types (database_url, url, etc.)
-      types = true,
-      path = vim.fn.getcwd(), -- Path to search for .env files
-      preferred_environment = "development", -- Optional: prioritize specific env files
     },
-  },
-}
+  })
 
-M.config = function() end
+  nmap("<Leader>cc", ":CloakToggle<cr>")
+end
 
 return M

+ 62 - 4
lua/plugins/lsp/extras/typescript.lua

@@ -1,10 +1,68 @@
 return {
-  "yioneko/nvim-vtsls",
+  "pmizio/typescript-tools.nvim",
   dependencies = {
-    "dmmulroy/ts-error-translator.nvim",
+    "nvim-lua/plenary.nvim",
+    "neovim/nvim-lspconfig",
   },
+  ft = { "typescript", "javascript", "jsx", "tsx", "json" },
   config = function()
-    require("ts-error-translator").setup()
+    local lsp_common = require("plugins.lsp").get_common_config()
+    local ts_api = require("typescript-tools.api")
+    local original_on_attach = lsp_common.on_attach
+
+    lsp_common.on_attach = function(client, bufnr)
+      original_on_attach(client, bufnr)
+      vim.keymap.set("n", "<leader>ca", function()
+        local diagnostics = vim.diagnostic.get(0, { lnum = vim.fn.line(".") - 1 })
+        local context = { diagnostics = diagnostics }
+        local params = vim.lsp.util.make_range_params(0)
+        params.context = context
+
+        params = vim.tbl_extend("force", {}, params)
+        vim.lsp.buf_request(bufnr, "textDocument/codeAction", params, function(err, result, ctx)
+          local actions = result or {}
+          table.insert(actions, { title = "Organize Imports", command = "typescript.custom.organize_imports" })
+          table.insert(actions, { title = "Fix All", command = "typescript.custom.fix_all" })
+          table.insert(actions, { title = "Add Missing Imports", command = "typescript.custom.add_missing_imports" })
+          table.insert(actions, { title = "Remove Unused", command = "typescript.custom.remove_unused" })
+          vim.ui.select(actions, {
+            prompt = "Code Actions",
+            format_item = function(action)
+              return action.title
+            end,
+          }, function(action)
+            if not action then
+              return
+            end
+            if action.command == "typescript.custom.organize_imports" then
+              pcall(ts_api.organize_imports)
+            elseif action.command == "typescript.custom.fix_all" then
+              pcall(ts_api.fix_all)
+            elseif action.command == "typescript.custom.add_missing_imports" then
+              pcall(ts_api.add_missing_imports)
+            elseif action.command == "typescript.custom.remove_unused" then
+              pcall(ts_api.remove_unused)
+            else
+              if action.edit or type(action.command) == "table" then
+                if action.edit then
+                  vim.lsp.util.apply_workspace_edit(action.edit, "utf-8")
+                end
+                if type(action.command) == "table" then
+                  vim.lsp.buf.execute_command(action.command)
+                end
+              end
+            end
+          end)
+        end)
+      end, { buffer = bufnr, desc = "Code Actions" })
+    end
+
+    require("typescript-tools").setup(vim.tbl_deep_extend("force", lsp_common, {
+      settings = {
+        separate_diagnostic_server = true,
+        publish_diagnostic_on = "insert_leave",
+        expose_as_code_action = {},
+      },
+    }))
   end,
-  ft = { "typescript", "javascript", "jsx", "tsx", "json" },
 }

+ 33 - 30
lua/plugins/lsp/init.lua

@@ -30,9 +30,22 @@ end
 
 -- Set up key mappings for LSP functionality
 local function setup_keymaps(bufnr)
+  local BORDER = "rounded"
   local keymaps = {
-    { "<C-h>", vim.lsp.buf.signature_help, "Signature Help" },
-    -- { "K", vim.lsp.buf.hover, "Hover Doc"},
+    {
+      "<C-h>",
+      function()
+        vim.lsp.buf.signature_help({ border = BORDER })
+      end,
+      "Signature Help",
+    },
+    {
+      "K",
+      function()
+        vim.lsp.buf.hover({ border = BORDER })
+      end,
+      "Hover Doc",
+    },
     { "<leader>cw", vim.lsp.buf.rename, "Rename" },
     { "<leader>r", vim.lsp.buf.rename, "Rename" },
     { "vd", vim.diagnostic.open_float, "Open Diagnostics" },
@@ -49,18 +62,27 @@ local function setup_keymaps(bufnr)
 end
 
 -- Function called when LSP attaches to a buffer
-local function on_attach(client, bufnr)
+function M.on_attach(client, bufnr)
   setup_autocommands(client, bufnr)
   setup_keymaps(bufnr)
 end
 
-local BORDER = "rounded"
+-- Function to get common LSP configuration
+function M.get_common_config()
+  local capabilities = require("blink.cmp").get_lsp_capabilities()
 
--- 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 }),
-}
+  -- Enable folding capabilities
+  capabilities.textDocument.foldingRange = {
+    dynamicRegistration = false,
+    lineFoldingOnly = true,
+  }
+
+  return {
+    on_attach = M.on_attach,
+    capabilities = capabilities,
+    flags = { debounce_text_changes = 150 },
+  }
+end
 
 function M.config()
   -- Set up Mason
@@ -78,7 +100,6 @@ function M.config()
     "json-lsp",
     "lua-language-server",
     "omnisharp",
-    "vtsls",
     "yaml-language-server",
     "svelte-language-server",
 
@@ -118,20 +139,7 @@ function M.config()
     },
     handlers = {
       function(server_name)
-        local capabilities = require("blink.cmp").get_lsp_capabilities()
-
-        -- Enable folding capabilities
-        capabilities.textDocument.foldingRange = {
-          dynamicRegistration = false,
-          lineFoldingOnly = true,
-        }
-
-        local base_opts = {
-          on_attach = on_attach,
-          capabilities = capabilities,
-          handlers = handlers,
-          flags = { debounce_text_changes = 150 },
-        }
+        local base_opts = M.get_common_config()
 
         -- Load server-specific configuration if it exists
         local ok, server_opts = pcall(require, "config.lsp." .. server_name)
@@ -148,12 +156,7 @@ function M.config()
   -- 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 },
-    })
+    require("lspconfig")[server].setup(M.get_common_config())
   end
 end