From 67a83e2466ea8b7abc74141f887fd39a1e9016cb Mon Sep 17 00:00:00 2001 From: Skladnayazebra Date: Thu, 9 Apr 2026 12:20:42 +0200 Subject: reconfigure treesitter for NeoVim 0.12; move stuff around --- nvim/lua/config/keymaps.lua | 27 ++++++++++++++++++++++ nvim/lua/config/lsp.lua | 6 +++++ nvim/lua/config/plugins/tree-sitter.lua | 40 ++++++++++++++++++--------------- nvim/lua/config/trailing-spaces.lua | 16 +++++++++++++ 4 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 nvim/lua/config/keymaps.lua create mode 100644 nvim/lua/config/trailing-spaces.lua (limited to 'nvim/lua/config') diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..de2c737 --- /dev/null +++ b/nvim/lua/config/keymaps.lua @@ -0,0 +1,27 @@ + +vim.keymap.set('n', 'c', 'c', { noremap = true, silent = true, desc = 'Close window' }) +vim.keymap.set('n', 'o', 'o', { noremap = true, silent = true, desc = 'Close other windows' }) + +-- z means laZy (plugin manager) +vim.keymap.set('n', 'z', ':Lazy', { noremap = true, silent = true, desc = 'Open Lazy.nvim' }) + +-- LSP binds +-- default gd searches only in current buffer as a keyword +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { noremap = true, silent = true, desc = 'Open definition' }) + +-- Fugitive shortcuts +vim.keymap.set('n', 'gd', ':Gvdiffsplit', { noremap = true, silent = true, desc = 'Git diff (unstaged changes)' }) +vim.keymap.set('n', 'gD', ':Gvdiffsplit HEAD', { noremap = true, silent = true, desc = 'Git diff (all changes after HEAD)' }) +vim.keymap.set('n', 'gs', ':Git', { noremap = true, silent = true, desc = 'Git status' }) +vim.keymap.set('n', 'gb', ':Git blame', { noremap = true, silent = true, desc = 'Git blame' }) +vim.keymap.set('n', 'gl', ':Git log', { noremap = true, silent = true, desc = 'Git log' }) +vim.keymap.set('n', 'gL', ':0Gclog', { noremap = true, silent = true, desc = 'Git log: this file' }) +vim.keymap.set('n', 'ge', ':Gedit', { noremap = true, silent = true, desc = 'Git: return to worktree' }) + +vim.keymap.set('n', 'e', ':lua MiniFiles.open(vim.api.nvim_buf_get_name(0), false)', { noremap = true, silent = true, desc = 'File Explorer' }) +vim.keymap.set('n', 'aa', ':argadd:argdedupe', { noremap = true, silent = true, desc = 'Add to args' }) +vim.keymap.set('n', 'ad', ':argdelete %', { noremap = true, silent = true, desc = 'Delete from args' }) +vim.keymap.set('n', 'lr', ':LspRestart', { noremap = true, silent = true, desc = 'LSP: restart' }) +vim.keymap.set('n', 'lx', ':LspStop', { noremap = true, silent = true, desc = 'LSP: stop' }) +vim.keymap.set('n', 'll', ':LspStart', { noremap = true, silent = true, desc = 'LSP: start' }) +vim.keymap.set('n', 'li', ':LspInfo', { noremap = true, silent = true, desc = 'LSP: info' }) diff --git a/nvim/lua/config/lsp.lua b/nvim/lua/config/lsp.lua index b12b10d..6507c67 100644 --- a/nvim/lua/config/lsp.lua +++ b/nvim/lua/config/lsp.lua @@ -1,3 +1,9 @@ +-- LSP diagnostic info config (erorrs, warnings, etc.) +vim.diagnostic.config({ + -- use virtual text to show diagnostic messages + virtual_text = true, +}) + -- requires json language service - npm i -g vscode-langservers-extracted vim.lsp.enable('jsonls') vim.lsp.config('jsonls', { diff --git a/nvim/lua/config/plugins/tree-sitter.lua b/nvim/lua/config/plugins/tree-sitter.lua index d37f98b..a692c37 100644 --- a/nvim/lua/config/plugins/tree-sitter.lua +++ b/nvim/lua/config/plugins/tree-sitter.lua @@ -1,27 +1,31 @@ return { { "nvim-treesitter/nvim-treesitter", - branch = 'master', + branch = 'main', lazy = false, build = ":TSUpdate", config = function() - require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the listed parsers MUST always be installed) - ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" }, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - highlight = { - enable = true, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - } + require('nvim-treesitter').install { + "bash", + "c", + "css", + "gitignore", + "html", + "ini", -- .npmrc + "javascript", + "json", + "lua", + "lua", + "markdown", + "markdown_inline", -- code blocks inside .md + "query", + "scss", + "tsx", + "typescript", + "vim", + "vimdoc", + "yaml", + } end } } diff --git a/nvim/lua/config/trailing-spaces.lua b/nvim/lua/config/trailing-spaces.lua new file mode 100644 index 0000000..2bb4cbf --- /dev/null +++ b/nvim/lua/config/trailing-spaces.lua @@ -0,0 +1,16 @@ +-- highlights trailing spaces +vim.cmd('match Search /\\s\\+$/') + +-- disable highlight when going into insert mode +vim.api.nvim_create_autocmd({'ModeChanged'}, { + pattern = {'*:i'}, + command = 'match none', +}) + +-- highlights trailing spaces when going back to normal mode +vim.api.nvim_create_autocmd({'ModeChanged'}, { + pattern = {'*:n'}, + command = 'match Search /\\s\\+$/', +}) + +vim.keymap.set('n', 't', ':%s/\\s\\+$//g', { noremap = true, silent = true, desc = 'Remove Trailing Whitespaces' }) -- cgit v1.3.1