Procházet zdrojové kódy

gitsings changes + try fixing tree sitter

Noah Vogt před 3 dny
rodič
revize
482e9f9919

+ 7 - 0
dot-config/nvim/general/auto.vim

@@ -97,3 +97,10 @@ augroup END
 augroup fixVimSpectorLogFile
 autocmd User VimspectorDebugEnded call system("mv ~/.vimspector.log " . $XDG_CACHE_HOME."/vim/")
 augroup END
+
+" Highlight references on CursorHold
+augroup LspHighlight
+  autocmd!
+  autocmd CursorHold * lua vim.lsp.buf.document_highlight()
+  autocmd CursorMoved * lua vim.lsp.buf.clear_references()
+augroup END

+ 8 - 4
dot-config/nvim/init.vim

@@ -2,9 +2,12 @@
 
 " 1. Essential Neovim 0.11+ fixes and environment setup
 lua << EOF
--- Ensure site directory is in rtp for Treesitter
-vim.opt.runtimepath:prepend(vim.fn.expand("~/.local/share/nvim/site"))
-vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/site")
+-- Add paths to RTP
+local site = vim.fn.expand("~/.local/share/nvim/site/")
+local ts_runtime = vim.fn.expand("~/.cache/vim/plugged/nvim-treesitter/runtime/")
+
+vim.opt.runtimepath:prepend(site)
+vim.opt.runtimepath:prepend(ts_runtime)
 
 -- Disable built-in LSP mappings (using native LSP in lsp.lua)
 local builtins = { 'grn', 'gra', 'grr', 'gri', 'grt' }
@@ -36,9 +39,10 @@ source $XDG_CONFIG_HOME/nvim/plug-conf/vimspector.vim
 " 4. Lua configurations
 lua require 'treesitter'
 lua require 'lsp'
+lua require 'telescope-conf'
+lua require 'refactoring-conf'
 lua require 'gitsigns-conf'
 lua require 'indent-blankline'
-lua require 'telescope'
 lua require 'whichkey'
 lua require 'colorizer'.setup()
 

+ 4 - 0
dot-config/nvim/keys/bindings.vim

@@ -58,6 +58,10 @@ nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
 
 nnoremap <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
 
+" LSP code actions (Extract function, organize imports, etc.)
+nnoremap <leader>a <cmd>lua vim.lsp.buf.code_action()<CR>
+xnoremap <leader>a <cmd>lua vim.lsp.buf.code_action()<CR>
+
 " switch (back and forth) to (and from) the last opened file
 nmap <leader>b <c-^><cr>
 

+ 44 - 0
dot-config/nvim/lua/gitsigns-conf.lua

@@ -0,0 +1,44 @@
+require('gitsigns').setup({
+  signs = {
+    add          = { text = '+' },
+    change       = { text = '~' },
+    delete       = { text = '_' },
+    topdelete    = { text = '‾' },
+    changedelete = { text = '~' },
+    untracked    = { text = '┆' },
+  },
+  -- Enable highlighting for the sign column and line numbers
+  signcolumn = true,
+  numhl      = true, 
+  linehl     = false,
+  word_diff  = false,
+  
+  on_attach = function(bufnr)
+    local gs = package.loaded.gitsigns
+
+    local function map(mode, l, r, opts)
+      opts = opts or {}
+      opts.buffer = bufnr
+      vim.keymap.set(mode, l, r, opts)
+    end
+
+    -- Navigation
+    map('n', ']h', function()
+      if vim.wo.diff then return ']h' end
+      vim.schedule(function() gs.next_hunk() end)
+      return '<Ignore>'
+    end, {expr=true})
+
+    map('n', '[h', function()
+      if vim.wo.diff then return '[h' end
+      vim.schedule(function() gs.prev_hunk() end)
+      return '<Ignore>'
+    end, {expr=true})
+
+    -- Actions
+    map('n', '<leader>hs', gs.stage_hunk)
+    map('n', '<leader>hr', gs.reset_hunk)
+    map('n', '<leader>hp', gs.preview_hunk)
+    map('n', '<leader>hb', function() gs.blame_line{full=true} end)
+  end
+})

+ 1 - 1
dot-config/nvim/lua/lsp.lua

@@ -33,7 +33,7 @@ end
 local capabilities = blink.get_lsp_capabilities()
 
 -- Basic servers
-local servers = { 'pyright', 'bashls', 'html', 'cssls', 'jdtls' }
+local servers = { 'pyright', 'ruff', 'bashls', 'html', 'cssls', 'jdtls' }
 for _, server in ipairs(servers) do
   vim.lsp.config(server, {
     capabilities = capabilities,

+ 15 - 0
dot-config/nvim/lua/refactoring-conf.lua

@@ -0,0 +1,15 @@
+local refactoring = require('refactoring')
+refactoring.setup({})
+
+-- Use which-key to register the mapping explicitly
+local wk = require("which-key")
+wk.add({
+  { "<leader>r", group = "refactor" },
+  {
+    mode = { "x" },
+    { "<leader>re", function() require('refactoring').select_refactor() end, desc = "Refactor Menu" },
+    { "<leader>rv", function() require('refactoring').refactor('Extract Variable') end, desc = "Extract Variable" },
+    { "<leader>rf", function() require('refactoring').refactor('Extract Function') end, desc = "Extract Function" },
+    { "<leader>ri", function() require('refactoring').refactor('Inline Variable') end, desc = "Inline Variable" },
+  },
+})

+ 2 - 0
dot-config/nvim/lua/telescope.lua → dot-config/nvim/lua/telescope-conf.lua

@@ -104,3 +104,5 @@ telescope.setup {
     -- please take a look at the readme of the extension you want to configure
   },
 }
+
+telescope.load_extension('refactoring')

+ 1 - 0
dot-config/nvim/vim-plug/plugins.vim

@@ -40,6 +40,7 @@ Plug 'lewis6991/gitsigns.nvim'
 
 " native LSP support
 Plug 'neovim/nvim-lspconfig'
+Plug 'ThePrimeagen/refactoring.nvim'
 " modern completion engine
 Plug 'Saghen/blink.cmp'
 " snippet support