diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-12-11 20:46:32 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-12-11 20:47:59 +0100 |
commit | f22f1723c01b56da14ae1de3491a78af1bc4c464 (patch) | |
tree | 030411c811d3474c4b322eca29d1bf8e96b7511f /.config/nvim | |
parent | d8713792f93473fe14e01d151529fb6ef139448f (diff) |
Dot files with `chezmoi`
Diffstat (limited to '.config/nvim')
-rw-r--r-- | .config/nvim/after/ftdetect/antlr4.vim | 1 | ||||
-rw-r--r-- | .config/nvim/after/ftdetect/jolie.vim | 1 | ||||
-rwxr-xr-x | .config/nvim/after/ftdetect/prr.vim | 1 | ||||
-rwxr-xr-x | .config/nvim/after/ftplugin/dockerfile.vim | 1 | ||||
-rwxr-xr-x | .config/nvim/after/ftplugin/json.vim | 1 | ||||
-rwxr-xr-x | .config/nvim/after/ftplugin/markdown.vim | 1 | ||||
-rw-r--r-- | .config/nvim/after/syntax/antlr4.vim | 93 | ||||
-rw-r--r-- | .config/nvim/after/syntax/jolie.vim | 59 | ||||
-rwxr-xr-x | .config/nvim/after/syntax/prr.vim | 22 | ||||
-rw-r--r-- | .config/nvim/init.lua | 214 | ||||
-rw-r--r-- | .config/nvim/lua/dap_conf.lua | 52 | ||||
-rw-r--r-- | .config/nvim/lua/git.lua | 65 | ||||
-rw-r--r-- | .config/nvim/lua/lsp_conf.lua | 114 |
13 files changed, 0 insertions, 625 deletions
diff --git a/.config/nvim/after/ftdetect/antlr4.vim b/.config/nvim/after/ftdetect/antlr4.vim deleted file mode 100644 index d4d39a1..0000000 --- a/.config/nvim/after/ftdetect/antlr4.vim +++ /dev/null @@ -1 +0,0 @@ -autocmd BufEnter,BufNewFile *.g4 setf antlr4 diff --git a/.config/nvim/after/ftdetect/jolie.vim b/.config/nvim/after/ftdetect/jolie.vim deleted file mode 100644 index efa43f7..0000000 --- a/.config/nvim/after/ftdetect/jolie.vim +++ /dev/null @@ -1 +0,0 @@ -au BufRead,BufNewFile *.ol,*.iol set filetype=jolie diff --git a/.config/nvim/after/ftdetect/prr.vim b/.config/nvim/after/ftdetect/prr.vim deleted file mode 100755 index 15a474c..0000000 --- a/.config/nvim/after/ftdetect/prr.vim +++ /dev/null @@ -1 +0,0 @@ -au BufNewFile,BufRead *.prr set filetype=prr diff --git a/.config/nvim/after/ftplugin/dockerfile.vim b/.config/nvim/after/ftplugin/dockerfile.vim deleted file mode 100755 index b388056..0000000 --- a/.config/nvim/after/ftplugin/dockerfile.vim +++ /dev/null @@ -1 +0,0 @@ -let g:indentLine_enabled = 0 diff --git a/.config/nvim/after/ftplugin/json.vim b/.config/nvim/after/ftplugin/json.vim deleted file mode 100755 index b388056..0000000 --- a/.config/nvim/after/ftplugin/json.vim +++ /dev/null @@ -1 +0,0 @@ -let g:indentLine_enabled = 0 diff --git a/.config/nvim/after/ftplugin/markdown.vim b/.config/nvim/after/ftplugin/markdown.vim deleted file mode 100755 index b388056..0000000 --- a/.config/nvim/after/ftplugin/markdown.vim +++ /dev/null @@ -1 +0,0 @@ -let g:indentLine_enabled = 0 diff --git a/.config/nvim/after/syntax/antlr4.vim b/.config/nvim/after/syntax/antlr4.vim deleted file mode 100644 index 8f6c412..0000000 --- a/.config/nvim/after/syntax/antlr4.vim +++ /dev/null @@ -1,93 +0,0 @@ -if exists('b:current_syntax') - finish -endif - -command -nargs=* HiLink highlight link <args> - -syntax match antlr4EventId +[a-zA-Z_][a-zA-Z0-9_]*+ contained -syntax match antlr4ParName +\<[a-z][a-zA-Z0-9_]*\>+ containedin=antlr4RHS -syntax match antlr4LexName +\<[A-Z][a-zA-Z0-9_]*\>+ containedin=antlr4RHS -syntax match antlr4Assign /[a-zA-Z]\++\?=/ containedin=antlr4RHS - -if exists('g:antlr4_highlight_punctuation') - syntax match antlr4Punctuation +[\-():;]+ -endif - -syntax include @included syntax/java.vim - -syntax region antlr4RHS start=+:+ end=+;+ extend - -syntax region antlr4Embed start=+{+ end=+}?\?+ contains=@included,antlr4Variable keepend - \ containedin=antlr4RHS -syntax region antlr4Embed start=+\[+ end=+\]+ contains=@included,antlr4Variable keepend - - -syntax match antlr4Repeat +[+*]+ containedin=antlr4RHS -syntax match antlr4Condition +?+ containedin=antlr4RHS -syntax match antlr4Option "|" containedin=antlr4RHS - -" Use specifically containedin=javaParenT so it will be highlighted inside -" parens -syntax match antlr4Variable contained +\$[a-zA-Z_][a-zA-Z0-9_]*+ containedin=javaParenT - -syntax match antlr4Keyword /@\(\(parser\|lexer\)::\)\?\(header\|members\)/ -syntax match antlr4Keyword /@after/ - -syntax match antlr4Escape +\\[nrvt]+ -syntax match antlr4Escape +\\u[0-9a-fA-F]\{4}+ -syntax match antlr4Escape +\\u{[0-9a-fA-F]\{4}}+ -syntax match antlr4Escape +\\p{.\{-}}+ - -syntax match antlr4SetEscape +\\-+ containedin=antlr4RHS - -syntax keyword antlr4Keyword grammar -syntax keyword antlr4Keyword lexer parser options -syntax keyword antlr4Keyword fragment tokens -syntax keyword antlr4Keyword returns locals throws catch finally mode options - -syntax keyword antlr4Import import - -syntax keyword antlr4Operation skip more popMode mode pushMode type channel - \ containedin=antlr4RHS - -syntax region antlr4Set start=+\[+ end=+\]+ contained - \ contains=antlr4Escape,antlr4SetEscape containedin=antlr4RHS -syntax region antlr4Attr start="<" end=">" - \ containedin=antlr4RHS -syntax region antlr4String start=+'+ end=+'+ containedin=antlr4RHS contains=antlr4Escape - -syntax region antlr4Comment start=+/\*+ end=+\*/+ - \ containedin=antlr4RHS -syntax region antlr4Comment start=+//+ end=+$+ - \ containedin=antlr4RHS - -syntax region antlr4Event start=+#+ end=+$+ - \ containedin=antlr4RHS contains=antlr4EventId - -HiLink antlr4Comment Comment -HiLink antlr4Keyword KeyWord -HiLink antlr4ParName Type -HiLink antlr4LexName Macro -HiLink antlr4Attr Special -HiLink antlr4Assign Statement -HiLink antlr4Set Character -HiLink antlr4String String - -if exists('g:antlr4_highlight_punctuation') - HiLink antlr4Punctuation Operator -endif - -HiLink antlr4Repeat Repeat -HiLink antlr4Condition Conditional -HiLink antlr4Option Delimiter -HiLink antlr4Import PreProc -HiLink antlr4Escape Special -HiLink antlr4SetEscape antlr4Escape -HiLink antlr4Operation Function -HiLink antlr4EventId Function -HiLink antlr4Annotation KeyWord -HiLink antlr4Variable Special - -delcommand HiLink - -let b:current_syntax = 'antlr4' diff --git a/.config/nvim/after/syntax/jolie.vim b/.config/nvim/after/syntax/jolie.vim deleted file mode 100644 index c7b3a21..0000000 --- a/.config/nvim/after/syntax/jolie.vim +++ /dev/null @@ -1,59 +0,0 @@ -if exists("b:current_syntax") - finish -endif - -syn keyword jolieBoolean true false -syn keyword jolieDefinitionTypes inputPort outputPort interface type define service -syn keyword jolieKeyword location Location protocol Protocol interfaces Interfaces aggregates Aggregates redirects Redirects class Jolie JavaScript Java OneWay oneWay RequestResponse requestResponse execution -syn keyword jolieOtherKeyword constants cH instanceof execution comp concurrent nullProcess single sequential main foreign java init cset is_defined embed embedded extender courier forward install undef include synchronized throws throw from import as -syn keyword jolieConditional if else -syn keyword jolieRepeat while for foreach until in -syn keyword jolieException throw -syn keyword jolieStatement forward scope provide -syn keyword jolieType void bool int string long double any raw -syn keyword jolieKeywordModifiers csets global -syn match jolieOperators "(<<|&&|\|\||+|-|/|*|=|==|++|-|+=|-=|*=|/=|!|%=|%)" - -syn match jolieSpecialChar contained "\\." - -syn region jolieString start=+"+ end=+"+ contains=jolieSpecialChar - -syn match jolieNumber "\<\d\+\>" - -syn match jolieMethodInvocation "\<\(\w\+\)@\(\w\+\)\>" contains=jolieMethodName,jolieClassName - -syn match jolieMethodName "\w\+@"me=e-1 contained -syn match jolieClassName "@\w\+\>"ms=s+1 contained - -syn match jolieMethodName2 "\(\w\+\)(" - -syn keyword jolieTodo contained TODO FIXME -syn region jolieComment start="/\*" end="\*/" contains=jolieTodo -syn match jolieLineComment "//.*" - -let b:current_syntax = "jolie" - -hi def link jolieBoolean Boolean -hi def link jolieComment Comment -hi def link jolieLineComment Comment -hi def link jolieDefinitionTypes Keyword -hi def link jolieKeyword Keyword -hi def link jolieOtherKeyword Keyword - -hi def link jolieOperators Operator - -hi def link jolieConditional Conditional -hi def link jolieRepeat Repeat -hi def link jolieException Exception -hi def link jolieStatement Statement -hi def link jolieType Type - -hi def link jolieKeywordModifiers StorageClass - -hi def link jolieString String - -hi def link jolieNumber Number - -hi def link jolieMethodName Function -hi def link jolieClassName Type -hi def link jolieMethodName2 Function diff --git a/.config/nvim/after/syntax/prr.vim b/.config/nvim/after/syntax/prr.vim deleted file mode 100755 index 43a0557..0000000 --- a/.config/nvim/after/syntax/prr.vim +++ /dev/null @@ -1,22 +0,0 @@ -" Vim syntax file -" Language: prr -" Maintainer: Daniel Xu <dxu@dxuuu.xyz> -" Last Change: 2022 Mar 25 -" Credits: Bram Moolenaar <Bram@vim.org> -" -" This version is copied and edited from diff.vim - -" Check whether an earlier file has defined a syntax already -if exists("b:current_syntax") - finish -endif - -syn match diffAdded "^> +.*" -syn match diffRemoved "^> -.*" - -" Define the default highlighting. -" Only used when an item doesn't have highlighting yet -hi def link diffAdded Type -hi def link diffRemoved Statement - -let b:current_syntax = "prr" diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua deleted file mode 100644 index 8415c94..0000000 --- a/.config/nvim/init.lua +++ /dev/null @@ -1,214 +0,0 @@ --- Auto-reload Neovim configuration on save -vim.cmd [[ - augroup packer_user_config - autocmd! - autocmd BufWritePost init.lua source <afile> | PackerCompile - augroup end -]] - -require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - -- use 'cespare/vim-toml' -- TOML syntax highlighting - use 'rust-lang/rust.vim' -- Rust language support - use 'nvim-lua/plenary.nvim' -- Lua utilities for plugins - use 'lewis6991/gitsigns.nvim' -- Git integration (show signs in gutter) - use 'kyazdani42/nvim-web-devicons'-- File icons - use 'mg979/vim-visual-multi' -- Multi-cursor support - use 'tpope/vim-fugitive' -- Git wrapper for commands like :Git - use 'ap/vim-css-color' -- Show color preview for CSS colors - -- use 'lukas-reineke/indent-blankline.nvim' -- Display vertical indentation lines - use 'google/vim-searchindex' -- Show search match count - use 'numToStr/Comment.nvim' -- Easily comment/uncomment lines - -- use 'togglebyte/togglerust' -- Rust debugging tools - -- use 'chriskempson/base16-vim' -- Base16 color schemes - use 'NLKNguyen/papercolor-theme' -- PaperColor theme - use 'nvim-telescope/telescope.nvim' -- Fuzzy finder - use 'neovim/nvim-lspconfig' -- LSP configuration for multiple languages - use 'hrsh7th/nvim-cmp' -- Autocompletion engine - use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp - use 'saadparwaiz1/cmp_luasnip' -- Snippet completion for nvim-cmp - use 'L3MON4D3/LuaSnip' -- Snippet engine - use 'kyazdani42/nvim-tree.lua' -- File explorer - use 'ray-x/lsp_signature.nvim' -- Show function signatures as you type - use 'folke/todo-comments.nvim' -- Highlight and search TODO comments - use 'saecki/crates.nvim' -- Rust crate version management - use { - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate' -- Update treesitter parsers - } - use 'folke/trouble.nvim' -- Diagnostics and references list - use 'folke/lsp-colors.nvim' -- Adds missing LSP diagnostics highlight groups - use 'sindrets/diffview.nvim' -- Git diff and history viewer - - use 'mfussenegger/nvim-dap' -- Debug Adapter Protocol client implementation - use 'leoluz/nvim-dap-go' -- Neovim DAP extension for Go - use 'nvim-neotest/nvim-nio' - use 'rcarriga/nvim-dap-ui' - - -- Automatically set up the configuration after cloning packer.nvim - if packer_bootstrap then - require('packer').sync() - end -end) - --- General Neovim settings - --- Configure completion options (menu, menuone, noselect) -vim.opt.completeopt = "menu,menuone,noselect" - --- Enable system clipboard access -vim.opt.clipboard = "unnamedplus" - --- Enable mouse support in all modes -vim.opt.mouse = "a" - --- Enable command-line completion features -vim.opt.wildmenu = true -vim.opt.wildmode = { "longest", "list", "full" } - --- Ignore certain file types when using wildmenu for file navigation -vim.opt.wildignore = "*.png,*.jpg,*.gif,*.swp,*.o,*.pyc,vendor" - --- Show absolute line numbers -vim.opt.number = true - --- Show relative line numbers -vim.opt.relativenumber = true - --- Set text width to 80 characters -vim.opt.textwidth = 80 - --- Highlight a column at 80 characters -vim.opt.colorcolumn = "80" - --- Disable line wrapping -vim.opt.wrap = false - --- Set tab width and shift width to 4 spaces -vim.opt.tabstop = 4 -vim.opt.shiftwidth = 4 - --- Use spaces instead of tabs -vim.opt.expandtab = true - --- Automatically indent new lines to match the previous line -vim.opt.autoindent = true - --- Automatically reload files if they are modified outside of Neovim -vim.opt.autoread = true - --- Set UTF-8 as the default encoding -vim.opt.encoding = "UTF-8" - --- Set the history size for command line and search -vim.opt.history = 1000 - --- Highlight search matches -vim.opt.hlsearch = true - --- Incrementally search while typing -vim.opt.incsearch = true - --- Disable backup file creation -vim.opt.backup = false - --- Set the status line to always be visible -vim.opt.laststatus = 2 - --- Show invisible characters (e.g., tabs, spaces, etc.) -vim.opt.list = true - --- Define characters for different invisible characters -vim.opt.listchars = { eol = '⏎', tab = '»·', trail = 'ˑ', nbsp = '⎵' } - --- Use indent-based folding -vim.opt.foldmethod = "indent" - --- Open vertical splits to the right of the current window -vim.opt.splitright = true - --- Open horizontal splits below the current window -vim.opt.splitbelow = true - --- Optimize screen redrawing for performance -vim.opt.lazyredraw = true - --- Disable swapfile creation -vim.opt.swapfile = false - --- Enable 24-bit RGB color in the terminal -vim.opt.termguicolors = true - --- Set background to dark mode -vim.opt.background = "dark" - --- Highlight the current line -vim.opt.cursorline = true - --- **Highlight settings** --- Set custom highlights for various UI components -vim.cmd('colorscheme PaperColor') -vim.cmd [[ - highlight Normal guibg=#000000 - highlight NonText guibg=#000000 - highlight LineNr guibg=#000000 - highlight CursorLine guibg=#000000 - highlight CursorLineNr guibg=#000000 guifg=Yellow - highlight StatusLine guibg=#000000 guifg=Yellow - highlight StatusLineNC guibg=#000000 guifg=Yellow - highlight SignColumn guibg=#000000 - highlight GitGutterChange guibg=#000000 - highlight GitGutterAdd guibg=#000000 - highlight GitGutterDelete guibg=#000000 -]] - --- Keybindings -vim.g.mapleader = "," -- Set the leader key to "," -vim.api.nvim_set_keymap('n', 'j', 'gj', { noremap = true }) -- Move down visually wrapped lines -vim.api.nvim_set_keymap('n', 'k', 'gk', { noremap = true }) -- Move up visually wrapped lines - ----- Buffers -vim.api.nvim_set_keymap('n', ']b', ':bnext<CR>', { noremap = true, silent = true }) -- Move to the next buffer -vim.api.nvim_set_keymap('n', '[b', ':bprev<CR>', { noremap = true, silent = true }) -- Move to the previous buffer -vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Telescope buffers<CR>', { noremap = true, silent = true }) -- List and switch to buffers using Telescope - ----- Tabs -vim.api.nvim_set_keymap('n', 'tn', ':tabnew<CR>', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', ']t', ':tabn<CR>', { noremap = true, silent = true }) -- Move to the next tab -vim.api.nvim_set_keymap('n', '[t', ':tabp<CR>', { noremap = true, silent = true }) -- Move to the previous tab - -vim.api.nvim_set_keymap('n', '<leader>o', ':only<CR>', { noremap = true }) -- Close all other windows -vim.api.nvim_set_keymap('n', '<C-t>', ':NvimTreeToggle<CR>', { noremap = true }) -- Toggle NvimTree file explorer -vim.api.nvim_set_keymap('n', '<leader>pa', ':set paste<CR>', { noremap = true }) -- Enable paste mode -vim.api.nvim_set_keymap('n', '<leader>npa', ':set nopaste<CR>', { noremap = true }) -- Disable paste mode -vim.api.nvim_set_keymap('n', '<leader>cr', ':Cargo run<CR>', { noremap = true }) -- Run `cargo run` for Rust projects -vim.api.nvim_set_keymap('n', '<leader>xx', '<cmd>TroubleToggle<cr>', { noremap = true }) -- Toggle Trouble diagnostic window -vim.api.nvim_set_keymap('n', '<leader>ff', '<cmd>Telescope find_files<cr>', { noremap = true }) -- Find files with Telescope -vim.api.nvim_set_keymap('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', { noremap = true }) -- Live grep with Telescope -vim.api.nvim_set_keymap('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', { noremap = true }) -- Search help tags with Telescope -vim.api.nvim_set_keymap('n', '<C-i>', ':lua vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())<CR>', { noremap = true }) - --- Custom command aliases for Diffview -vim.api.nvim_create_user_command('Do', 'DiffviewOpen', {}) -vim.api.nvim_create_user_command('Dc', 'DiffviewClose', {}) -vim.api.nvim_create_user_command('Dh', 'DiffviewFileHistory', {}) - - --- Plugin configuration -require('nvim-tree').setup { actions = { open_file = { quit_on_open = true } } } -require('todo-comments').setup {} -require('crates').setup {} -require('nvim-treesitter.configs').setup { highlight = { enable = true } } -require('lsp-colors').setup {} --- require("ibl").setup { indent = {char = "¦"} } --- vim.cmd.highlight('clear @ibl.scope.underline.1') - --- General settings -require('git') -- Load git-related settings -require('lsp_conf') -- Load LSP configuration -require('dap_conf') - --- Set up language client for Go -vim.g.LanguageClient_serverCommands = { go = { 'gopls' } } diff --git a/.config/nvim/lua/dap_conf.lua b/.config/nvim/lua/dap_conf.lua deleted file mode 100644 index b3cee89..0000000 --- a/.config/nvim/lua/dap_conf.lua +++ /dev/null @@ -1,52 +0,0 @@ -local dap, dapui = require('dap'), require('dapui') -local dapgo = require('dap-go') -dapui.setup() -dapgo.setup() -dap.listeners.before.attach.dapui_config = function() - dapui.open() -end -dap.listeners.before.launch.dapui_config = function() - dapui.open() -end - -dap.adapters.gdb = { - type = "executable", - command = "gdb", - args = { "--interpreter=dap", "--eval-command", "set print pretty on" } -} - -local configurations = {'c', 'cpp', 'rust'} - -for _, conf in ipairs(configurations) do - dap.configurations[conf] = { - { - name = "Launch", - type = "gdb", - request = "launch", - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - cwd = "${workspaceFolder}", - stopAtBeginningOfMainSubprogram = false, - }, - } -end - --- Include the next few lines until the comment only if you feel you need it -dap.listeners.before.event_terminated.dapui_config = function() - dapui.close() -end -dap.listeners.before.event_exited.dapui_config = function() - dapui.close() -end --- Include everything after this - - -vim.keymap.set('n', '<F5>', function() require('dap').continue() end) -vim.keymap.set('n', '<F10>', function() require('dap').step_over() end) -vim.keymap.set('n', '<F11>', function() require('dap').step_into() end) -vim.keymap.set('n', '<F12>', function() require('dap').step_out() end) -vim.keymap.set('n', '<C-K>', function() require('dap').toggle_breakpoint() end) -vim.api.nvim_create_user_command('DapRepeat',function() require('dap').run_last() end, {}) -vim.api.nvim_create_user_command('DapOpen',function() dapui.open() end, {}) -vim.api.nvim_create_user_command('DapClose',function() dapui.close() end, {}) diff --git a/.config/nvim/lua/git.lua b/.config/nvim/lua/git.lua deleted file mode 100644 index da6bbdd..0000000 --- a/.config/nvim/lua/git.lua +++ /dev/null @@ -1,65 +0,0 @@ -require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '-' }, - topdelete = { text = '-' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, - }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - follow_files = true - }, - attach_to_untracked = true, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - }, - current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>', - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, -- Disable if file is longer than this (in lines) - preview_config = { - -- Options passed to nvim_open_win - border = 'single', - style = 'minimal', - relative = 'cursor', - row = 0, - col = 1 - }, - 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 - - map('n', ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '<Ignore>' - end, {expr=true}) - - map('n', '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '<Ignore>' - end, {expr=true}) - - map('n', 'hs', gs.stage_hunk) - map('v', 'hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) - map('n', 'hS', gs.stage_buffer) - map('n', 'hu', gs.undo_stage_hunk) - map('n', 'hp', gs.preview_hunk) - map('n', 'hB', gs.blame_line) - end -} diff --git a/.config/nvim/lua/lsp_conf.lua b/.config/nvim/lua/lsp_conf.lua deleted file mode 100644 index a93dc5b..0000000 --- a/.config/nvim/lua/lsp_conf.lua +++ /dev/null @@ -1,114 +0,0 @@ -local nvim_lsp = require('lspconfig') -local trouble = require("trouble") - -local capabilities = require("cmp_nvim_lsp").default_capabilities() - --- Redefine LSP diagnostic signs -local signs = { Error = 'E', Warning = 'W', Hint = 'H', Information = 'I' } - -for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) -end - -local opts = { noremap=true, silent=true } - --- Setup lsp_signature for function signature help -require "lsp_signature".setup() - --- Common on_attach function to handle keymaps and settings for all LSPs -local common_on_attach = function(client, bufnr) - -- Key mappings - vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "ga", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) - vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) - -- Use vim.diagnostic.open_float for showing line diagnostics (replacing deprecated call) - vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", opts) - vim.keymap.set('n', '<A-f>', '<cmd>lua vim.lsp.buf.format {async = true}<cr>', opts) - - -- Autoformat on save - vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.format {async = true}") -end - --- LSP servers setup -local servers = { - 'clangd', - 'gopls', - 'jdtls', - 'metals', - 'ocamllsp', - 'ruff_lsp', - 'rust_analyzer', -} - -capabilities.offsetEncoding = { "utf-16" } - -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - capabilities = capabilities, - on_attach = common_on_attach, - flags = { - debounce_text_changes = 150, - } - } -end - -nvim_lsp.ts_ls.setup { - capabilities = capabilities, - on_attach = common_on_attach, - filetypes = { "typescript", "typescriptreact", "typescript.tsx" }, - cmd = { "typescript-language-server", "--stdio" } -} - -vim.lsp.inlay_hint.enable(true, { 0 }) - --- Trouble setup -trouble.setup({ - use_diagnostic_signs = true, - auto_close = true, - auto_open = false -}) - --- nvim-cmp setup for autocompletion -local luasnip = require 'luasnip' -local cmp = require 'cmp' -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - ['<C-d>'] = cmp.mapping.scroll_docs(-4), - ['<C-f>'] = cmp.mapping.scroll_docs(4), - ['<C-Space>'] = cmp.mapping.complete(), - ['<CR>'] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - ['<Tab>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - ['<S-Tab>'] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }), - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - }, -} |