diff --git a/.gitignore b/.gitignore index de23def..a074298 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ -plugin/packer-compiled.lua -*.log +tags +test.sh +.luarc.json +nvim + +spell/ + +.DS_Store diff --git a/README.md b/README.md index 845599d..cc37340 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,5 @@ -# Neovim Config +# Neovim config -To ignore changes to local plugins file. Used for keeping computer specific configs/plugins -```shell -git update-index --assume-unchanged lua/plugins-local.lua -``` +It might to be the best, it might contains bugs, but it's mine and I like it. -## Requirements -* ripgrep - for telescope -* [A patched font](https://www.nerdfonts.com/) - for icons - -## Todo -* Automatic updating of comments at `#endif`, -```c -#ifdef FOOBAR -// ... -#endif // FOOBAR -// The text "FOOBAR" above should update when the paring `#ifdef` updates -``` -* Correctly indent `#ifdef` blocks -* Fix cmacro indent to not reformat lines, if nothing needs to be changed +Used [kickstart.nvim#f0a2108](https://github.com/nvim-lua/kickstart.nvim/tree/f0a2108ed51547793c758d9318bad94f242b22e5) as a template diff --git a/init.lua b/init.lua index f0352c6..c91ca62 100644 --- a/init.lua +++ b/init.lua @@ -1,1070 +1,877 @@ --- Set as the leader key --- See `:help mapleader` -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' +-- ============================================================ +-- SECTION 1: OPTIONS +-- Core Neovim settings, leaders, options, basic keymaps, basic autocmds +-- ============================================================ +do + -- Enable faster startup by caching compiled Lua modules + vim.loader.enable() --- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = true + -- Set as the leader key + vim.g.mapleader = ' ' + vim.g.maplocalleader = ' ' --- If possible use 24 Bit Colors -if vim.fn.has 'termguicolors' == 1 then - vim.o.termguicolors = true + -- If possible use 24 Bit Colors + if vim.fn.has 'termguicolors' == 1 then + vim.o.termguicolors = true + end + + -- Set to true if you have a Nerd Font installed and selected in the terminal + vim.g.have_nerd_font = true + + -- [[ Setting options ]] + -- See `:help vim.o` + + -- Make line numbers default + vim.o.number = true + vim.o.relativenumber = true + + -- Enable mouse mode, can be useful for resizing splits for example! + vim.o.mouse = 'a' + + -- Don't show the mode, since it's already in the status line + vim.o.showmode = false + + -- Formatting is just too slow. So just disable it. + vim.g.zig_fmt_autosave = 0 + + -- Sync clipboard between OS and Neovim. + -- Schedule the setting after `UiEnter` because it can increase startup-time. + -- Remove this option if you want your OS clipboard to remain independent. + -- See `:help 'clipboard'` + vim.schedule(function() vim.o.clipboard = 'unnamedplus' end) + + -- Enable break indent + vim.o.breakindent = true + + -- Folding options + vim.o.foldmethod = 'indent' + vim.o.foldlevelstart = 99 + + -- Enable undo/redo changes even after closing and reopening a file + vim.o.undofile = true + vim.opt.undodir = '/tmp/vim-undodir' + vim.opt.swapfile = false + vim.opt.writebackup = false + vim.opt.backup = false + + -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term + vim.o.ignorecase = true + vim.o.smartcase = true + + -- Keep signcolumn on by default + vim.o.signcolumn = 'yes' + + -- Decrease update time + vim.o.updatetime = 250 + + -- Decrease mapped sequence wait time + vim.o.timeoutlen = 300 + + -- Configure how new splits should be opened + vim.o.splitright = true + vim.o.splitbelow = true + + -- Sets how neovim will display certain whitespace characters in the editor. + -- See `:help 'list'` + -- and `:help 'listchars'` + -- + -- Notice listchars is set using `vim.opt` instead of `vim.o`. + -- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. + -- See `:help lua-options` + -- and `:help lua-guide-options` + vim.o.list = true + vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + + -- Preview substitutions live, as you type! + vim.o.inccommand = 'split' + + -- Show which line your cursor is on + vim.o.cursorline = true + + -- Minimal number of screen lines to keep above and below the cursor. + vim.o.scrolloff = 10 + + -- Remove cmdline when not used + vim.o.cmdheight = 0 + + -- Show 110 marker column + vim.o.colorcolumn = '110' + + -- Keep non-visible files open + vim.o.hidden = true + + -- Skip redrawing window while executing macro + vim.o.lazyredraw = true + + -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), + -- instead raise a dialog asking if you wish to save the current file(s) + -- See `:help 'confirm'` + vim.o.confirm = true + + if vim.g.neovide then + vim.g.neovide_scale_factor = 0.8 + end end --- [[ Setting options ]] --- See `:help vim.opt` - --- Enable auto reload of changed files -vim.o.autoread = true - --- Make line numbers default -vim.opt.number = true -vim.opt.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' - --- Don't show the mode, since it's already in the status line -vim.opt.showmode = false - --- Formatting is just too slow. So just disable it. -vim.g.zig_fmt_autosave = 0 - --- Sync clipboard between OS and Neovim. --- Schedule the setting after `UiEnter` because it can increase startup-time. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' -end) - --- Enable break indent -vim.opt.breakindent = true - --- Folding options -vim.o.foldmethod = 'indent' -vim.o.foldlevelstart = 99 - --- Save undo history -vim.opt.undofile = true -vim.opt.undodir = '/tmp/vim-undodir' -vim.opt.swapfile = false -vim.opt.writebackup = false -vim.opt.backup = false - --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' - --- Decrease update time -vim.opt.updatetime = 250 - --- Decrease mapped sequence wait time --- Displays which-key popup sooner -vim.opt.timeoutlen = 300 - --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true - --- Sets how neovim will display certain whitespace characters in the editor. --- See `:help 'list'` --- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - --- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' - --- Show which line your cursor is on -vim.opt.cursorline = true - --- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 - --- Remove cmdline when not used -vim.o.cmdheight = 0 - --- Show 110 marker column -vim.o.colorcolumn = '110' - --- Keep non-visible files open -vim.o.hidden = true - --- Skip redrawing window while executing macro -vim.o.lazyredraw = true - --- Place splits below and to the right by default -vim.o.splitbelow = true -vim.o.splitright = true - --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` -vim.keymap.set('n', '', 'nohlsearch') - --- Diagnostic keymaps -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - --- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier --- for people to discover. Otherwise, you normally need to press , which --- is not what someone will guess without a bit more experience. --- --- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping --- or just use to exit terminal mode -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands --- vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) --- vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) --- vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) --- vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- Better indenting -vim.keymap.set('v', '<', '', '>gv') - --- Save file -vim.keymap.set('n', '', ':w', { noremap = true, silent = true }) - --- Disable Ex mode -vim.keymap.set('n', 'Q', '') - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - -vim.api.nvim_create_autocmd('BufWritePre', { - pattern = { '*.zig', '*.zon' }, - callback = function(ev) - vim.lsp.buf.code_action { - context = { only = { 'source.fixAll' } }, - apply = true, - } - end, -}) - --- Override `ft` for .h files to `c` -vim.api.nvim_create_autocmd('FileType', { - group = vim.api.nvim_create_augroup('override-c-header-ft', { clear = true }), - pattern = 'cpp', - callback = function(data) - if data.file:match '%.h$' then - vim.api.nvim_set_option_value('ft', 'c', { buf = data.buf }) - end - end, -}) - --- Add abbreviation for != => ~= in lua files -vim.api.nvim_create_autocmd('BufEnter', { - group = vim.api.nvim_create_augroup('MyTermOpen', { clear = true }), - pattern = '*.lua', - callback = function() - vim.api.nvim_cmd({ cmd = 'abb', args = { '', '!=', '~=' } }, {}) - end, -}) - --- [[ Install `lazy.nvim` plugin manager ]] --- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } - if vim.v.shell_error ~= 0 then - error('Error cloning lazy.nvim:\n' .. out) - end -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) - --- [[ Configure and install plugins ]] -require('lazy').setup({ - -- Add spacing so that data looks like a table - 'godlygeek/tabular', - - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', - - -- Smooth scrolling. TODO: Only enable this if not in neovide - -- 'psliwka/vim-smoothie', - - -- Select indented text - 'michaeljsmith/vim-indent-object', - - -- Detect and apply editorconfig settings - 'editorconfig/editorconfig-vim', - - -- Better quickfix window - 'kevinhwang91/nvim-bqf', - - { - 'backdround/global-note.nvim', - config = function() - require('global-note').setup {} - end, - keys = { - { - 'n', - function() - require('global-note').toggle_note() - end, - desc = 'Toggle [N]otes', - }, - }, - }, - - { - 'kdheepak/lazygit.nvim', - keys = { - { 'g', 'LazyGit', desc = 'Open lazygit' }, - }, - }, - - { - 'stevearc/dressing.nvim', - dependencies = { 'nvim-telescope/telescope.nvim' }, - opts = { - select = { - get_config = function(opts) - opts = opts or {} - local cfg = { - telescope = { - layout_config = { - -- width = 120, - -- height = 60, - width = 0.87, - height = 0.80, - }, - }, - } - if opts.kind == 'legendary.nvim' then - cfg.telescope.sorter = require('telescope.sorters').fuzzy_with_index_bias {} - end - return cfg - end, - }, - }, - }, - - { - 'MunsMan/kitty-navigator.nvim', - build = { - 'cp navigate_kitty.py ~/.config/kitty', - 'cp pass_keys.py ~/.config/kitty', - }, - opts = { keybindings = {} }, - }, - - { 'tikhomirov/vim-glsl', ft = 'glsl' }, - - { - 'nvim-treesitter/playground', - requires = 'nvim-treesitter/nvim-treesitter', - cmd = 'TSPlaygroundToggle', - }, - - { - 'vim-scripts/DoxygenToolkit.vim', - cmd = 'Dox', - config = function() - vim.g.DoxygenToolkit_startCommentTag = '/// ' - vim.g.DoxygenToolkit_interCommentTag = '/// ' - vim.g.DoxygenToolkit_endCommentTag = '' - vim.g.DoxygenToolkit_startCommentBlock = '// ' - vim.g.DoxygenToolkit_interCommentBlock = '// ' - vim.g.DoxygenToolkit_endCommentBlock = '' - end, - }, - - { - 'fedepujol/move.nvim', - opts = {}, - config = function() - require('move').setup {} - local opts = { noremap = true, silent = true } - vim.keymap.set('v', '', ':MoveBlock(1)', opts) - vim.keymap.set('v', '', ':MoveBlock(-1)', opts) - end, - }, - - { - 'norcalli/nvim-colorizer.lua', - lazy = false, - config = function() - require('colorizer').setup(nil, { - RGB = true, - RRGGBB = true, - names = false, - RRGGBBAA = true, - rgb_fn = true, - hsl_fn = true, - css = false, - css_fn = false, - mode = 'background', - }) - end, - }, - - { - 'stevearc/oil.nvim', - opts = { - default_file_explorer = true, - skip_confirm_for_simple_edits = true, - }, - -- Optional dependencies - -- dependencies = { { "echasnovski/mini.icons", opts = {} } }, - dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if prefer nvim-web-devicons - }, - - { - 'unblevable/quick-scope', - init = function() - -- Trigger a highlight in the appropriate direction when pressing these keys: - vim.g.qs_highlight_on_keys = { 'f', 'F', 't', 'T' } - vim.g.qs_max_chars = 150 - end, - }, - - { - dir = '~/.config/nvim/lua/personal/uci', - config = function() - require('personal.uci.init').load() - end, - ft = 'uci', - }, - - { - dir = '~/.config/nvim/lua/personal/uci', - config = function() - require('personal.add-include-guard').load() - end, - cmd = 'AddIncludeGuard', - }, - - { - 'folke/zen-mode.nvim', - opts = { - plugins = { - gitsigns = { enabled = true }, - }, - }, - }, - - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. This is equivalent to the following Lua: - -- require('gitsigns').setup({ ... }) - -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `opts` key (recommended), the configuration runs - -- after the plugin has been loaded as `require(MODULE).setup(opts)`. - - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - opts = { - icons = { - -- set icon mappings to true if you have a Nerd Font - mappings = vim.g.have_nerd_font, - -- If you are using a Nerd Font: set icons.keys to an empty table which will use the - -- default which-key.nvim defined Nerd Font icons, otherwise define a string table - keys = vim.g.have_nerd_font and {} or { - Up = ' ', - Down = ' ', - Left = ' ', - Right = ' ', - C = ' ', - M = ' ', - D = ' ', - S = ' ', - CR = ' ', - Esc = ' ', - ScrollWheelDown = ' ', - ScrollWheelUp = ' ', - NL = ' ', - BS = ' ', - Space = ' ', - Tab = ' ', - F1 = '', - F2 = '', - F3 = '', - F4 = '', - F5 = '', - F6 = '', - F7 = '', - F8 = '', - F9 = '', - F10 = '', - F11 = '', - F12 = '', - }, - }, - - -- Document existing key chains - spec = { - { 'c', group = '[C]ode', mode = { 'n', 'x' } }, - { 'd', group = '[D]ocument' }, - { 'r', group = '[R]ename' }, - { 's', group = '[S]earch' }, - { 'w', group = '[W]orkspace' }, - { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, - }, - }, - }, - - -- - -- The dependencies are proper plugin specifications as well - anything - -- you do for a plugin at the top level, you can do for a dependency. - -- - -- Use the `dependencies` key to specify the dependencies of a particular plugin - - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, - }, - - -- LSP Plugins - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, - }, - }, - { 'Bilal2453/luvit-meta', lazy = true }, - { - -- Main LSP Configuration - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - { 'j-hui/fidget.nvim', opts = {} }, - - -- Allows extra capabilities provided by nvim-cmp - 'hrsh7th/cmp-nvim-lsp', - }, - config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end - end, - }) - - -- Change diagnostic symbols in the sign column (gutter) - if vim.g.have_nerd_font then - local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' } - local diagnostic_signs = {} - for type, icon in pairs(signs) do - diagnostic_signs[vim.diagnostic.severity[type]] = icon - end - vim.diagnostic.config { signs = { text = diagnostic_signs } } - end - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, - -- - zls = {}, - - lua_ls = { - -- cmd = { ... }, - -- filetypes = { ... }, - -- capabilities = {}, - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - }, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - require('mason').setup() - - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format Lua code - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, - - { -- Autoformat - 'stevearc/conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { - 'f', - function() - require('conform').format { async = true, lsp_format = 'fallback' } - end, - mode = '', - desc = '[F]ormat buffer', - }, - }, - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true, zig = true } - local lsp_format_opt - if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' - else - lsp_format_opt = 'fallback' - end - return { - timeout_ms = 500, - lsp_format = lsp_format_opt, +-- ============================================================ +-- SECTION 2: KEYMAPS +-- basic keymaps +-- ============================================================ +do + -- [[ Basic Keymaps ]] + -- See `:help vim.keymap.set()` + + -- Clear highlights on search when pressing in normal mode + -- See `:help hlsearch` + vim.keymap.set('n', '', 'nohlsearch') + + -- Diagnostic Config & Keymaps + -- See `:help vim.diagnostic.Opts` + vim.diagnostic.config { + update_in_insert = false, + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = { min = vim.diagnostic.severity.WARN } }, + + -- Can switch between these as you prefer + virtual_text = true, -- Text shows up at the end of the line + virtual_lines = false, -- Text shows up underneath the line, with virtual lines + + -- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d` + jump = { + on_jump = function(_, bufnr) + vim.diagnostic.open_float { + bufnr = bufnr, + scope = 'cursor', + focus = false, } end, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, - }, }, - }, + } - { -- Autocompletion - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - -- `friendly-snippets` contains a variety of premade snippets. - -- See the README about individual language/framework/plugin snippets: - -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, - }, - }, - 'saadparwaiz1/cmp_luasnip', + vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', - }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} + -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier + -- for people to discover. Otherwise, you normally need to press , which + -- is not what someone will guess without a bit more experience. + -- + -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping + -- or just use to exit terminal mode + vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, + -- TIP: Disable arrow keys in normal mode + -- vim.keymap.set('n', '', 'echo "Use h to move!!"') + -- vim.keymap.set('n', '', 'echo "Use l to move!!"') + -- vim.keymap.set('n', '', 'echo "Use k to move!!"') + -- vim.keymap.set('n', '', 'echo "Use j to move!!"') - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), + -- Keybinds to make split navigation easier. + -- Use CTRL+ to switch between windows + -- + -- See `:help wincmd` for a list of all window commands + vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) + vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) + vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) + vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - -- Scroll the documentation window [b]ack / [f]orward - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), + -- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes + -- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) + -- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) + -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) + -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + -- Better indenting + vim.keymap.set('v', '<', '', '>gv') - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + -- Save file + vim.keymap.set('n', '', ':w', { noremap = true, silent = true }) - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [''] = cmp.mapping.complete {}, + -- Disable Ex mode + vim.keymap.set('n', 'Q', '') - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), + -- [[ Basic Autocommands ]] + -- See `:help lua-guide-autocommands` - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - sources = { - { - name = 'lazydev', - -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0, - }, - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, - } - end, - }, + -- Highlight when yanking (copying) text + -- Try it with `yap` in normal mode + -- See `:help vim.hl.on_yank()` + vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() vim.hl.on_yank() end, + }) - { - 'srcery-colors/srcery-vim', - priority = 1000, - config = function() - vim.cmd.colorscheme 'srcery' - end, - }, - - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - 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() - - local function recording_macro() - local reg = vim.api.nvim_call_function('reg_recording', {}) - if reg ~= '' then - return '@' .. reg - else - return '' - end + vim.api.nvim_create_autocmd('FileType', { + group = vim.api.nvim_create_augroup('override-c-header-ft', { clear = true }), + pattern = 'cpp', + callback = function(data) + if data.file:match '%.h$' then + vim.api.nvim_set_option_value('ft', 'c', { buf = data.buf }) end - - local statusline = require 'mini.statusline' - statusline.setup { - content = { - active = function() - local mode, mode_hl = MiniStatusline.section_mode { trunc_width = 120 } - local git = MiniStatusline.section_git { trunc_width = 40 } - local diff = MiniStatusline.section_diff { trunc_width = 75 } - local diagnostics = MiniStatusline.section_diagnostics { trunc_width = 75 } - local lsp = MiniStatusline.section_lsp { trunc_width = 75 } - local filename = MiniStatusline.section_filename { trunc_width = 140 } - local fileinfo = MiniStatusline.section_fileinfo { trunc_width = 120 } - local location = MiniStatusline.section_location { trunc_width = 75 } - local search = MiniStatusline.section_searchcount { trunc_width = 75 } - - return MiniStatusline.combine_groups { - { hl = mode_hl, strings = { mode } }, - { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp, recording_macro() } }, - '%<', -- Mark general truncate point - { hl = 'MiniStatuslineFilename', strings = { filename } }, - '%=', -- End left alignment - { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } }, - { hl = mode_hl, strings = { search, location } }, - } - end, - }, - -- set use_icons to true if you have a Nerd Font - use_icons = vim.g.have_nerd_font, - } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim end, - }, - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - }, + }) - -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the - -- init.lua. If you want these files, they are in the repository, so you can just download them and - -- place them in the correct locations. - - require 'kickstart.plugins.debug', - require 'kickstart.plugins.indent_line', - require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - require 'kickstart.plugins.gitsigns', -}, { - ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the - -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table - icons = vim.g.have_nerd_font and {} or { - cmd = '⌘', - config = '🛠', - event = '📅', - ft = '📂', - init = '⚙', - keys = '🗝', - plugin = '🔌', - runtime = '💻', - require = '🌙', - source = '📄', - start = '🚀', - task = '📌', - lazy = '💤 ', - }, - }, -}) - -if vim.g.neovide then - vim.g.neovide_scale_factor = 0.8 + -- Add abbreviation for != => ~= in lua files + vim.api.nvim_create_autocmd('BufEnter', { + group = vim.api.nvim_create_augroup('MyTermOpen', { clear = true }), + pattern = '*.lua', + callback = function() + vim.api.nvim_cmd({ cmd = 'abb', args = { '', '!=', '~=' } }, {}) + end, + }) +end + +-- ============================================================ +-- SECTION 3: PLUGIN MANAGER INTRO +-- vim.pack intro, build hooks +-- ============================================================ +do + local function run_build(name, cmd, cwd) + local result = vim.system(cmd, { cwd = cwd }):wait() + if result.code ~= 0 then + local stderr = result.stderr or '' + local stdout = result.stdout or '' + local output = stderr ~= '' and stderr or stdout + if output == '' then output = 'No output from build command.' end + vim.notify(('Build failed for %s:\n%s'):format(name, output), vim.log.levels.ERROR) + end + end + + -- This autocommand runs after a plugin is installed or updated and + -- runs the appropriate build command for that plugin if necessary. + -- + -- See `:help vim.pack-events` + vim.api.nvim_create_autocmd('PackChanged', { + callback = function(ev) + local name = ev.data.spec.name + local kind = ev.data.kind + if kind ~= 'install' and kind ~= 'update' then return end + + if name == 'telescope-fzf-native.nvim' and vim.fn.executable 'make' == 1 then + run_build(name, { 'make' }, ev.data.path) + return + end + + if name == 'LuaSnip' then + if vim.fn.has 'win32' ~= 1 and vim.fn.executable 'make' == 1 then run_build(name, { 'make', 'install_jsregexp' }, ev.data.path) end + return + end + + if name == 'kitty-navigator.nvim' then + run_build(name, { + 'cp navigate_kitty.py ~/.config/kitty', + 'cp pass_keys.py ~/.config/kitty' + }, ev.data.path) + end + + if name == 'nvim-treesitter' then + if not ev.data.active then vim.cmd.packadd 'nvim-treesitter' end + vim.cmd 'TSUpdate' + return + end + end, + }) +end + +---Because most plugins are hosted on GitHub, you can use the helper +---function to have less repetition in the following sections. +---@param repo string +---@return string +local function gh(repo) return 'https://github.com/' .. repo end + +-- ============================================================ +-- SECTION 4: UI / CORE UX PLUGINS +-- guess-indent, gitsigns, which-key, colorscheme, todo-comments, mini modules +-- ============================================================ +do + -- Add spacing so that data looks like a table + vim.pack.add { gh 'godlygeek/tabular' } + + -- Smooth scrolling. TODO: Only enable this if not in neovide + vim.pack.add { gh 'psliwka/vim-smoothie' } + + -- Select indented text + vim.pack.add { gh 'michaeljsmith/vim-indent-object' } + + -- Detect and apply editorconfig settings + vim.pack.add { gh 'editorconfig/editorconfig-vim' } + + -- Better quickfix window + vim.pack.add { gh 'kevinhwang91/nvim-bqf' } + + vim.pack.add { gh 'NMAC427/guess-indent.nvim' } + require('guess-indent').setup {} + + vim.pack.add { gh 'lewis6991/gitsigns.nvim' } + require('gitsigns').setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, ---@diagnostic disable-line: missing-fields + }, + } + + -- Useful plugin to show you pending keybinds. + vim.pack.add { gh 'folke/which-key.nvim' } + ---@diagnostic disable-next-line: missing-fields + require('which-key').setup { + -- Delay between pressing a key and opening which-key (milliseconds) + delay = 500, + icons = { mappings = vim.g.have_nerd_font }, + -- Document existing key chains + spec = { + { 's', group = '[S]earch', mode = { 'n', 'v' } }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, -- Enable gitsigns recommended keymaps first + { 'gr', group = 'LSP Actions', mode = { 'n' } }, + }, + } + + -- [[ Colorscheme ]] + vim.pack.add { gh 'srcery-colors/srcery-vim' } + vim.cmd.colorscheme 'srcery' + + -- Highlight todo, notes, etc in comments + vim.pack.add { gh 'folke/todo-comments.nvim' } + require('todo-comments').setup { signs = false } + + -- [[ mini.nvim ]] + -- A collection of various small independent plugins/modules + vim.pack.add { gh 'nvim-mini/mini.nvim' } + + -- If a nerd font is available, load the icons module for pretty icons in various plugins. + if vim.g.have_nerd_font then + require('mini.icons').setup() + -- Used for backwards compatibility with plugins that require `nvim-web-devicons` (e.g. telescope.nvim) + MiniIcons.mock_nvim_web_devicons() + end + + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yiiq - [Y]ank [I]nside [I]+1 [Q]uote + -- - ci' - [C]hange [I]nside [']quote + require('mini.ai').setup { + -- NOTE: Avoid conflicts with the built-in incremental selection mappings on Neovim>=0.12 (see `:help treesitter-incremental-selection`) + mappings = { + around_next = 'aa', + inside_next = 'ii', + }, + 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() + + -- Simple and easy statusline. + -- You could remove this setup call if you don't like it, + -- and try some other statusline plugin + local statusline = require 'mini.statusline' + -- Set `use_icons` to true if you have a Nerd Font + statusline.setup { use_icons = vim.g.have_nerd_font } + + -- You can configure sections in the statusline by overriding their + -- default behavior. For example, here we set the section for + -- cursor location to LINE:COLUMN + ---@diagnostic disable-next-line: duplicate-set-field + statusline.section_location = function() return '%2l:%-2v' end + + -- ... and there is more! + -- Check out: https://github.com/nvim-mini/mini.nvim + + -- Add spacing so that data looks like a table + vim.pack.add { gh 'kdheepak/lazygit.nvim' } + vim.keymap.set({ 'n', 'v' }, 'g', 'LazyGit', { desc = 'Open lazygit' }) + + vim.pack.add { gh 'vim-scripts/DoxygenToolkit.vim' } + vim.g.DoxygenToolkit_startCommentTag = '/// ' + vim.g.DoxygenToolkit_interCommentTag = '/// ' + vim.g.DoxygenToolkit_endCommentTag = '' + vim.g.DoxygenToolkit_startCommentBlock = '// ' + vim.g.DoxygenToolkit_interCommentBlock = '// ' + vim.g.DoxygenToolkit_endCommentBlock = '' + + vim.pack.add { gh 'tikhomirov/vim-glsl' } + + vim.pack.add { gh 'MunsMan/kitty-navigator.nvim' } + require("kitty-navigator").setup({ keybindings = {} }) ---@diagnostic disable-line: missing-fields + + vim.pack.add { gh 'fedepujol/move.nvim' } + require('move').setup {} + local opts = { noremap = true, silent = true } + vim.keymap.set('v', '', ':MoveBlock(1)', opts) + vim.keymap.set('v', '', ':MoveBlock(-1)', opts) + + vim.pack.add { gh 'catgoose/nvim-colorizer.lua' } + require('colorizer').setup({ + RGB = true, + RRGGBB = true, + names = false, + RRGGBBAA = true, + rgb_fn = true, + hsl_fn = true, + css = false, + css_fn = false, + mode = 'background', + }) + + vim.pack.add { gh 'stevearc/oil.nvim' } + require('oil').setup({ + default_file_explorer = true, + skip_confirm_for_simple_edits = true, + }) + + vim.pack.add { gh 'unblevable/quick-scope' } + -- Trigger a highlight in the appropriate direction when pressing these keys: + vim.g.qs_highlight_on_keys = { 'f', 'F', 't', 'T' } + vim.g.qs_max_chars = 150 +end + +-- ============================================================ +-- SECTION 5: SEARCH & NAVIGATION +-- Telescope setup, keymaps, LSP picker mappings +-- ============================================================ +do + ---@type (string|vim.pack.Spec)[] + local telescope_plugins = { + gh 'nvim-lua/plenary.nvim', + gh 'nvim-telescope/telescope.nvim', + gh 'nvim-telescope/telescope-ui-select.nvim', + } + if vim.fn.executable 'make' == 1 then table.insert(telescope_plugins, gh 'nvim-telescope/telescope-fzf-native.nvim') end + + -- NOTE: You can install multiple plugins at once + vim.pack.add(telescope_plugins) + + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + extensions = { + ['ui-select'] = { require('telescope.themes').get_dropdown() }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set({ 'n', 'v' }, 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'sc', builtin.commands, { desc = '[S]earch [C]ommands' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Add Telescope-based LSP pickers when an LSP attaches to a buffer. + -- If you later switch picker plugins, this is where to update these mappings. + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('telescope-lsp-attach', { clear = true }), + callback = function(event) + local buf = event.buf + + -- Find references for the word under your cursor. + vim.keymap.set('n', 'grr', builtin.lsp_references, { buffer = buf, desc = '[G]oto [R]eferences' }) + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + vim.keymap.set('n', 'gri', builtin.lsp_implementations, { buffer = buf, desc = '[G]oto [I]mplementation' }) + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + vim.keymap.set('n', 'grd', builtin.lsp_definitions, { buffer = buf, desc = '[G]oto [D]efinition' }) + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + vim.keymap.set('n', 'gO', builtin.lsp_document_symbols, { buffer = buf, desc = 'Open Document Symbols' }) + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + vim.keymap.set('n', 'gW', builtin.lsp_dynamic_workspace_symbols, { buffer = buf, desc = 'Open Workspace Symbols' }) + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + vim.keymap.set('n', 'grt', builtin.lsp_type_definitions, { buffer = buf, desc = '[G]oto [T]ype Definition' }) + end, + }) + + -- Override default behavior and theme when searching + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set( + 'n', + 's/', + function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, + { desc = '[S]earch [/] in Open Files' } + ) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config', follow = true } end, { desc = '[S]earch [N]eovim files' }) +end + +-- ============================================================ +-- SECTION 6: LSP +-- LSP keymaps, server configuration, Mason tools installations +-- ============================================================ +do + -- Useful status updates for LSP. + vim.pack.add { gh 'j-hui/fidget.nvim' } + require('fidget').setup {} + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that Lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('grn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + local client = vim.lsp.get_client_by_id(event.data.client_id) + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client:supports_method('textDocument/inlayHint', event.buf) then + map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- See `:help lsp-config` for information about keys and how to configure + ---@type table + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`ts_ls`) will work just fine + -- ts_ls = {}, + + -- stylua = {}, -- Used to format Lua code + + -- Special Lua Config, as recommended by neovim help docs + lua_ls = { + on_init = function(client) + client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua) + + if client.workspace_folders then + local path = client.workspace_folders[1].name + if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + version = 'LuaJIT', + path = { 'lua/?.lua', 'lua/?/init.lua' }, + }, + workspace = { + checkThirdParty = false, + -- NOTE: this is a lot slower and will cause issues when working on your own configuration. + -- See https://github.com/neovim/nvim-lspconfig/issues/3189 + library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), { + '${3rd}/luv/library', + '${3rd}/busted/library', + }), + }, + }) + end, + ---@type lspconfig.settings.lua_ls + settings = { + Lua = { + format = { enable = false }, -- Disable formatting (formatting is done by stylua) + }, + }, + }, + } + + vim.pack.add { + gh 'neovim/nvim-lspconfig', + gh 'mason-org/mason.nvim', + gh 'mason-org/mason-lspconfig.nvim', + gh 'WhoIsSethDaniel/mason-tool-installer.nvim', + } + + -- Automatically install LSPs and related tools to stdpath for Neovim + require('mason').setup {} + + -- Ensure the servers and tools above are installed + -- + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + -- You can add other tools here that you want Mason to install + }) + + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + for name, server in pairs(servers) do + vim.lsp.config(name, server) + vim.lsp.enable(name) + end +end + +-- ============================================================ +-- SECTION 7: FORMATTING +-- conform.nvim setup and keymap +-- ============================================================ +do + -- [[ Formatting ]] + vim.pack.add { gh 'stevearc/conform.nvim' } + require('conform').setup { + notify_on_error = false, + format_on_save = function(bufnr) + -- You can specify filetypes to autoformat on save here: + local enabled_filetypes = { + -- lua = true, + -- python = true, + } + if enabled_filetypes[vim.bo[bufnr].filetype] then + return { timeout_ms = 500 } + else + return nil + end + end, + default_format_opts = { + lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely. + }, + -- You can also specify external formatters in here. + formatters_by_ft = { + -- rust = { 'rustfmt' }, + -- Conform can also run multiple formatters sequentially + -- python = { "isort", "black" }, + -- + -- You can use 'stop_after_first' to run the first available formatter from the list + -- javascript = { "prettierd", "prettier", stop_after_first = true }, + }, + } + + vim.keymap.set({ 'n', 'v' }, 'f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' }) +end + +-- ============================================================ +-- SECTION 8: AUTOCOMPLETE & SNIPPETS +-- blink.cmp and luasnip setup +-- ============================================================ +do + -- [[ Snippet Engine ]] + + -- NOTE: You can also specify plugin using a version range for its git tag. + -- See `:help vim.version.range()` for more info + vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } } + require('luasnip').setup {} + + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- + -- vim.pack.add { gh 'rafamadriz/friendly-snippets' } + -- require('luasnip.loaders.from_vscode').lazy_load() + + -- [[ Autocomplete Engine ]] + vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } } + require('blink.cmp').setup { + keymap = { + -- 'default' (recommended) for mappings similar to built-in completions + -- to accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + -- 'super-tab' for tab to accept + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- For an understanding of why the 'default' preset is recommended, + -- you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + -- + -- All presets have the following mappings: + -- /: move to right/left of your snippet expansion + -- : Open menu or open docs if already open + -- / or /: Select next/previous item + -- : Hide menu + -- : Toggle signature help + -- + -- See `:help blink-cmp-config-keymap` for defining your own keymap + preset = 'default', + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono', + }, + + completion = { + -- By default, you may press `` to show the documentation. + -- Optionally, set `auto_show = true` to show the documentation after a delay. + documentation = { auto_show = false, auto_show_delay_ms = 500 }, + }, + + sources = { + default = { 'lsp', 'path', 'snippets' }, + }, + + snippets = { preset = 'luasnip' }, + + -- Blink.cmp includes an optional, recommended rust fuzzy matcher, + -- which automatically downloads a prebuilt binary when enabled. + -- + -- By default, we use the Lua implementation instead, but you may enable + -- the rust implementation via `'prefer_rust_with_warning'` + -- + -- See `:help blink-cmp-config-fuzzy` for more information + fuzzy = { implementation = 'lua' }, + + -- Shows a signature help window while you type arguments for a function + signature = { enabled = true }, + } +end + +-- ============================================================ +-- SECTION 9: TREESITTER +-- Parser installation, syntax highlighting, folds, indentation +-- ============================================================ +do + -- [[ Configure Treesitter ]] + + -- NOTE: You can also specify a branch or a specific commit + vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } } + + -- Ensure basic parsers are installed + local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } + require('nvim-treesitter').install(parsers) + + ---@param buf integer + ---@param language string + local function treesitter_try_attach(buf, language) + -- Check if a parser exists and load it + if not vim.treesitter.language.add(language) then return end + -- Enable syntax highlighting and other treesitter features + vim.treesitter.start(buf, language) + + -- Enable treesitter based folds + -- For more info on folds see `:help folds` + -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + -- vim.wo.foldmethod = 'expr' + + -- Check if treesitter indentation is available for this language, and if so enable it + -- in case there is no indent query, the indentexpr will fallback to the vim's built in one + local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil + + -- Enable treesitter based indentation + if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end + end + + local available_parsers = require('nvim-treesitter').get_available() + vim.api.nvim_create_autocmd('FileType', { + callback = function(args) + local buf, filetype = args.buf, args.match + + local language = vim.treesitter.language.get_lang(filetype) + if not language then return end + + local installed_parsers = require('nvim-treesitter').get_installed 'parsers' + + if vim.tbl_contains(installed_parsers, language) then + -- Enable the parser if it is already installed + treesitter_try_attach(buf, language) + elseif vim.tbl_contains(available_parsers, language) then + -- If a parser is available in `nvim-treesitter`, auto-install it and enable it after the installation is done + require('nvim-treesitter').install(language):await(function() treesitter_try_attach(buf, language) end) + else + -- Try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + treesitter_try_attach(buf, language) + end + end, + }) +end + +-- ============================================================ +-- SECTION 10: OPTIONAL EXAMPLES / NEXT STEPS +-- kickstart.plugins.* examples +-- ============================================================ +do + require 'kickstart.plugins.debug' + require 'kickstart.plugins.indent_line' + require 'kickstart.plugins.lint' + -- require 'kickstart.plugins.autopairs' + -- require 'kickstart.plugins.neo-tree' + require 'kickstart.plugins.gitsigns' + + require('personal.uci') + require('personal.add-include-guard') end --- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 1b0f7aa..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "DoxygenToolkit.vim": { "branch": "master", "commit": "afd8663d36d2ec19d26befdb10e89e912d26bbd3" }, - "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, - "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "6632e7d788a85bf8405ea0c812d343fc308b7b8c" }, - "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, - "editorconfig-vim": { "branch": "master", "commit": "91bd0b0a2c6a72a110ab9feae335e1224480c233" }, - "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, - "gitsigns.nvim": { "branch": "main", "commit": "02eafb1273afec94447f66d1a43fc5e477c2ab8a" }, - "global-note.nvim": { "branch": "main", "commit": "1e0d4bba425d971ed3ce40d182c574a25507115c" }, - "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, - "kitty-navigator.nvim": { "branch": "main", "commit": "abaaa37fe14cf762a8957a64ff50d2233aff7fe6" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lazygit.nvim": { "branch": "main", "commit": "b9eae3badab982e71abab96d3ee1d258f0c07961" }, - "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "1255518cb067e038a4755f5cb3e980f79b6ab89c" }, - "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, - "mini.nvim": { "branch": "main", "commit": "ed581c333798e08a68fbe1aecfdf95d3c1432d3f" }, - "move.nvim": { "branch": "main", "commit": "cccbd4ea9049ca5f99f025ffaddb7392359c7d6a" }, - "nvim-bqf": { "branch": "main", "commit": "e20417d5e589e03eaaaadc4687904528500608be" }, - "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "7aade9e99bef5f0735cf966e715b3ce45515d786" }, - "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, - "nvim-dap-ui": { "branch": "master", "commit": "881a69e25bd6658864fab47450025490b74be878" }, - "nvim-lint": { "branch": "master", "commit": "3615c26c4922ae5f7366f0c1943a0e7cece04325" }, - "nvim-lspconfig": { "branch": "master", "commit": "32b6a6449aaba11461fffbb596dd6310af79eea4" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" }, - "nvim-web-devicons": { "branch": "master", "commit": "c90dee4e930ab9f49fa6d77f289bff335b49e972" }, - "oil.nvim": { "branch": "master", "commit": "302bbaceeafc690e6419e0c8296e804d60cb9446" }, - "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "quick-scope": { "branch": "master", "commit": "f2b6043e04d9ef05205c8953e389304a4c1946f2" }, - "srcery-vim": { "branch": "master", "commit": "d8915c0153ed451c975fa20356cb8c254232aa28" }, - "tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "vim-glsl": { "branch": "master", "commit": "40dd0b143ef93f3930a8a409f60c1bb85e28b727" }, - "vim-indent-object": { "branch": "master", "commit": "8ab36d5ec2a3a60468437a95e142ce994df598c6" }, - "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, - "vim-smoothie": { "branch": "master", "commit": "df1e324e9f3395c630c1c523d0555a01d2eb1b7e" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, - "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } -} diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua index b59d086..9910238 100644 --- a/lua/kickstart/health.lua +++ b/lua/kickstart/health.lua @@ -12,7 +12,7 @@ local check_version = function() return end - if vim.version.ge(vim.version(), '0.10-dev') then + if vim.version.ge(vim.version(), '0.12') then vim.health.ok(string.format("Neovim version is: '%s'", verstr)) else vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua index 87a7e5f..1d2cdab 100644 --- a/lua/kickstart/plugins/autopairs.lua +++ b/lua/kickstart/plugins/autopairs.lua @@ -1,16 +1,5 @@ -- autopairs -- https://github.com/windwp/nvim-autopairs -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, -} +vim.pack.add { 'https://github.com/windwp/nvim-autopairs' } +require('nvim-autopairs').setup {} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 753cb0c..db5448c 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -6,143 +6,90 @@ -- be extended to other languages as well. That's why it's called -- kickstart.nvim and not kitchen-sink.nvim ;) -return { - -- NOTE: Yes, you can install new plugins here! - 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', - - -- Required dependency for nvim-dap-ui - 'nvim-neotest/nvim-nio', - - -- Installs the debug adapters for you - 'williamboman/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', - }, - keys = { - -- Basic debugging keymaps, feel free to change to your liking! - { - '', - function() - require('dap').continue() - end, - desc = 'Debug: Start/Continue', - }, - { - '', - function() - require('dap').step_into() - end, - desc = 'Debug: Step Into', - }, - { - '', - function() - require('dap').step_over() - end, - desc = 'Debug: Step Over', - }, - { - '', - function() - require('dap').step_out() - end, - desc = 'Debug: Step Out', - }, - { - 'b', - function() - require('dap').toggle_breakpoint() - end, - desc = 'Debug: Toggle Breakpoint', - }, - { - 'B', - function() - require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, - desc = 'Debug: Set Breakpoint', - }, - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - { - '', - function() - require('dapui').toggle() - end, - desc = 'Debug: See last session result.', - }, - }, - config = function() - local dap = require 'dap' - local dapui = require 'dapui' - - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_installation = true, - - -- You can provide additional configuration to the handlers, - -- see mason-nvim-dap README for more information - handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) - ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', - }, - } - - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| - dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. - icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, - controls = { - icons = { - pause = '⏸', - play = '▶', - step_into = '⏎', - step_over = '⏭', - step_out = '⏮', - step_back = 'b', - run_last = '▶▶', - terminate = '⏹', - disconnect = '⏏', - }, - }, - } - - -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } - -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) - -- end - - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, - }, - } - end, +vim.pack.add { + 'https://github.com/mfussenegger/nvim-dap', + 'https://github.com/rcarriga/nvim-dap-ui', + 'https://github.com/nvim-neotest/nvim-nio', + 'https://github.com/mason-org/mason.nvim', + 'https://github.com/jay-babu/mason-nvim-dap.nvim', + 'https://github.com/leoluz/nvim-dap-go', +} + +-- Basic debugging keymaps, feel free to change to your liking! +vim.keymap.set('n', '', function() require('dap').continue() end, { desc = 'Debug: Start/Continue' }) +vim.keymap.set('n', '', function() require('dap').step_into() end, { desc = 'Debug: Step Into' }) +vim.keymap.set('n', '', function() require('dap').step_over() end, { desc = 'Debug: Step Over' }) +vim.keymap.set('n', '', function() require('dap').step_out() end, { desc = 'Debug: Step Out' }) +vim.keymap.set('n', 'b', function() require('dap').toggle_breakpoint() end, { desc = 'Debug: Toggle Breakpoint' }) +vim.keymap.set('n', 'B', function() require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, { desc = 'Debug: Set Breakpoint' }) +-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. +vim.keymap.set('n', '', function() require('dapui').toggle() end, { desc = 'Debug: See last session result.' }) + +local dap = require 'dap' +local dapui = require 'dapui' + +require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_installation = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, +} + +-- Dap UI setup +-- For more information, see |:help nvim-dap-ui| +---@diagnostic disable-next-line: missing-fields +dapui.setup { + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + ---@diagnostic disable-next-line: missing-fields + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, +} + +-- Change breakpoint icons +-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) +-- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) +-- local breakpoint_icons = vim.g.have_nerd_font +-- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } +-- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } +-- for type, icon in pairs(breakpoint_icons) do +-- local tp = 'Dap' .. type +-- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' +-- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) +-- end + +dap.listeners.after.event_initialized['dapui_config'] = dapui.open +dap.listeners.before.event_terminated['dapui_config'] = dapui.close +dap.listeners.before.event_exited['dapui_config'] = dapui.close + +-- Install golang specific config +require('dap-go').setup { + delve = { + -- On Windows delve must be run attached or it crashes. + -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring + detached = vim.fn.has 'win32' == 0, + }, } diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index 2d56875..b7e40a8 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -1,59 +1,57 @@ -- Adds git related signs to the gutter, as well as utilities for managing changes +-- NOTE: gitsigns is already included in init.lua but contains only the base +-- config. This will add also the recommended keymaps. -return { - { - 'lewis6991/gitsigns.nvim', - opts = { - on_attach = function(bufnr) - local gitsigns = require 'gitsigns' +vim.pack.add { 'https://github.com/lewis6991/gitsigns.nvim' } - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end +require('gitsigns').setup { + on_attach = function(bufnr) + local gitsigns = require 'gitsigns' - -- Navigation - map('n', ']c', function() - if vim.wo.diff then - vim.cmd.normal { ']c', bang = true } - else - gitsigns.nav_hunk 'next' - end - end, { desc = 'Jump to next git [c]hange' }) + 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 - vim.cmd.normal { '[c', bang = true } - else - gitsigns.nav_hunk 'prev' - end - end, { desc = 'Jump to previous git [c]hange' }) + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal { ']c', bang = true } + else + gitsigns.nav_hunk 'next' + end + end, { desc = 'Jump to next git [c]hange' }) - -- Actions - -- visual mode - map('v', 'hs', function() - gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'git [s]tage hunk' }) - map('v', 'hr', function() - gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'git [r]eset hunk' }) - -- normal mode - map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', 'hD', function() - gitsigns.diffthis '@' - end, { desc = 'git [D]iff against last commit' }) - -- Toggles - map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) - end, - }, - }, + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal { '[c', bang = true } + else + gitsigns.nav_hunk 'prev' + end + end, { desc = 'Jump to previous git [c]hange' }) + + -- Actions + -- visual mode + map('v', 'hs', function() gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } end, { desc = 'git [s]tage hunk' }) + map('v', 'hr', function() gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } end, { desc = 'git [r]eset hunk' }) + -- normal mode + map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', 'hi', gitsigns.preview_hunk_inline, { desc = 'git preview hunk [i]nline' }) + map('n', 'hb', function() gitsigns.blame_line { full = true } end, { desc = 'git [b]lame line' }) + map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', 'hD', function() gitsigns.diffthis '@' end, { desc = 'git [D]iff against last commit' }) + map('n', 'hQ', function() gitsigns.setqflist 'all' end, { desc = 'git hunk [Q]uickfix list (all files in repo)' }) + map('n', 'hq', gitsigns.setqflist, { desc = 'git hunk [q]uickfix list (all changes in this file)' }) + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', 'tw', gitsigns.toggle_word_diff, { desc = '[T]oggle git intra-line [w]ord diff' }) + + -- Text object + map({ 'o', 'x' }, 'ih', gitsigns.select_hunk) + end, } diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua index ed7f269..7187365 100644 --- a/lua/kickstart/plugins/indent_line.lua +++ b/lua/kickstart/plugins/indent_line.lua @@ -1,9 +1,6 @@ -return { - { -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help ibl` - main = 'ibl', - opts = {}, - }, -} +-- Add indentation guides even on blank lines + +-- Enable `lukas-reineke/indent-blankline.nvim` +-- See `:help ibl` +vim.pack.add { 'https://github.com/lukas-reineke/indent-blankline.nvim' } +require('ibl').setup {} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 6c40a81..d630544 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -1,60 +1,53 @@ -return { +-- Linting - { -- Linting - 'mfussenegger/nvim-lint', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local lint = require 'lint' - lint.linters_by_ft = { - markdown = {}, - } +vim.pack.add { 'https://github.com/mfussenegger/nvim-lint' } - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil - - -- Create autocommand which carries out the actual linting - -- on the specified events. - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - -- Only run the linter in buffers that you can modify in order to - -- avoid superfluous noise, notably within the handy LSP pop-ups that - -- describe the hovered symbol using Markdown. - if vim.opt_local.modifiable:get() then - lint.try_lint() - end - end, - }) - end, - }, +local lint = require 'lint' +lint.linters_by_ft = { + markdown = { 'markdownlint' }, -- Make sure to install `markdownlint` via mason / npm } + +-- To allow other plugins to add linters to require('lint').linters_by_ft, +-- instead set linters_by_ft like this: +-- lint.linters_by_ft = lint.linters_by_ft or {} +-- lint.linters_by_ft['markdown'] = { 'markdownlint' } +-- +-- However, note that this will enable a set of default linters, +-- which will cause errors unless these tools are available: +-- { +-- clojure = { "clj-kondo" }, +-- dockerfile = { "hadolint" }, +-- inko = { "inko" }, +-- janet = { "janet" }, +-- json = { "jsonlint" }, +-- markdown = { "vale" }, +-- rst = { "vale" }, +-- ruby = { "ruby" }, +-- terraform = { "tflint" }, +-- text = { "vale" } +-- } +-- +-- You can disable the default linters by setting their filetypes to nil: +-- lint.linters_by_ft['clojure'] = nil +-- lint.linters_by_ft['dockerfile'] = nil +-- lint.linters_by_ft['inko'] = nil +-- lint.linters_by_ft['janet'] = nil +-- lint.linters_by_ft['json'] = nil +-- lint.linters_by_ft['markdown'] = nil +-- lint.linters_by_ft['rst'] = nil +-- lint.linters_by_ft['ruby'] = nil +-- lint.linters_by_ft['terraform'] = nil +-- lint.linters_by_ft['text'] = nil + +-- Create autocommand which carries out the actual linting +-- on the specified events. +local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) +vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { + group = lint_augroup, + callback = function() + -- Only run the linter in buffers that you can modify in order to + -- avoid superfluous noise, notably within the handy LSP pop-ups that + -- describe the hovered symbol using Markdown. + if vim.bo.modifiable then lint.try_lint() end + end, +}) diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd44226..549629a 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -1,24 +1,19 @@ -- Neo-tree is a Neovim plugin to browse the file system -- https://github.com/nvim-neo-tree/neo-tree.nvim -return { - 'nvim-neo-tree/neo-tree.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended - 'MunifTanjim/nui.nvim', - }, - cmd = 'Neotree', - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, - }, - opts = { - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, +vim.pack.add { + { src = 'https://github.com/nvim-neo-tree/neo-tree.nvim', version = vim.version.range '*' }, + 'https://github.com/nvim-lua/plenary.nvim', + 'https://github.com/MunifTanjim/nui.nvim', +} + +vim.keymap.set('n', '\\', 'Neotree reveal', { desc = 'NeoTree reveal', silent = true }) + +require('neo-tree').setup { + filesystem = { + window = { + mappings = { + ['\\'] = 'close_window', }, }, }, diff --git a/lua/personal/add-include-guard/init.lua b/lua/personal/add-include-guard/init.lua index 117971d..a60f233 100644 --- a/lua/personal/add-include-guard/init.lua +++ b/lua/personal/add-include-guard/init.lua @@ -1,39 +1,33 @@ -local M = {} +-- TODO: Make it work with buffer which don't have a filename yet -function M.load() - -- TODO: Make it work with buffer which don't have a filename yet +vim.api.nvim_create_user_command('AddIncludeGuard', function(data) + local bufnr = vim.api.nvim_get_current_buf() + local name_pattern = data.fargs[1] or '%s_' - vim.api.nvim_create_user_command('AddIncludeGuard', function(data) - local bufnr = vim.api.nvim_get_current_buf() - local name_pattern = data.fargs[1] or '%s_' + local function formatName(filename) + local parts = vim.split(filename, '[/\\]', { trimempty = true }) + local last_part = parts[#parts] + local ext = last_part:match '%.([^%.]+)$' + local name = last_part:gsub('%.[^%.]+$', '') - local function formatName(filename) - local parts = vim.split(filename, '[/\\]', { trimempty = true }) - local last_part = parts[#parts] - local ext = last_part:match '%.([^%.]+)$' - local name = last_part:gsub('%.[^%.]+$', '') - - if ext == 'h' or ext == 'hpp' then - name = name .. '_H' - end - - return name_pattern:format(name:upper()) + if ext == 'h' or ext == 'hpp' then + name = name .. '_H' end - local buf_filename = vim.api.nvim_buf_get_name(bufnr) - local guard_name = formatName(buf_filename) + return name_pattern:format(name:upper()) + end - vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, { - '#ifndef ' .. guard_name, - '#define ' .. guard_name, - '', - }) + local buf_filename = vim.api.nvim_buf_get_name(bufnr) + local guard_name = formatName(buf_filename) - vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { - '', - '#endif //' .. guard_name, - }) - end, { nargs = '?' }) -end + vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, { + '#ifndef ' .. guard_name, + '#define ' .. guard_name, + '', + }) -return M + vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { + '', + '#endif //' .. guard_name, + }) +end, { nargs = '?' }) diff --git a/lua/personal/uci/init.lua b/lua/personal/uci/init.lua index 95056a5..af13956 100644 --- a/lua/personal/uci/init.lua +++ b/lua/personal/uci/init.lua @@ -1,40 +1,35 @@ -local M = {} -function M.load() - -- Setup tree sitter - local parser_config = require('nvim-treesitter.parsers').get_parser_configs() - parser_config.uci = { - install_info = { - url = 'git@rpuzonas.com:rpuzonas/tree-sitter-uci.git', - files = { 'src/parser.c' }, - branch = 'main', - generate_requires_npm = false, - requires_generate_from_grammar = false, - }, - filetype = 'uci', - } +-- Setup tree sitter +require('nvim-treesitter.parsers').uci = { + install_info = { + url = 'git@rpuzonas.com:rpuzonas/tree-sitter-uci.git', + files = { 'src/parser.c' }, + branch = 'main', + generate_requires_npm = false, + requires_generate_from_grammar = false, + }, + filetype = 'uci', +} - -- Determine UCI filetype by contents of file. - -- If file has no extension and at least one line contains the word "config" - -- TODO: - --[[ - vim.filetype.add({ - pattern = { - [".*/etc/config/.*"] = "uci", - [".*/[^%.]+"] = { - priority = -math.huge, - function(_, bufnr) - for _, line in ipairs(vim.filetype.getlines(bufnr)) do - if line:find("config") ~= nil then - return "uci" - end - end - end - } - } - }) - ]] - -- -end +-- Determine UCI filetype by contents of file. +-- If file has no extension and at least one line contains the word "config" +-- TODO: +--[[ +vim.filetype.add({ + pattern = { + [".*/etc/config/.*"] = "uci", + [".*/[^%.]+"] = { + priority = -math.huge, + function(_, bufnr) + for _, line in ipairs(vim.filetype.getlines(bufnr)) do + if line:find("config") ~= nil then + return "uci" + end + end + end + } + } +}) +]] +-- -return M diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..f96bf41 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,175 @@ +{ + "plugins": { + "DoxygenToolkit.vim": { + "rev": "afd8663d36d2ec19d26befdb10e89e912d26bbd3", + "src": "https://github.com/vim-scripts/DoxygenToolkit.vim" + }, + "LuaSnip": { + "rev": "642b0c595e11608b4c18219e93b88d7637af27bc", + "src": "https://github.com/L3MON4D3/LuaSnip", + "version": "2.0.0 - 3.0.0" + }, + "blink.cmp": { + "rev": "78336bc89ee5365633bcf754d93df01678b5c08f", + "src": "https://github.com/saghen/blink.cmp", + "version": "1.0.0 - 2.0.0" + }, + "conform.nvim": { + "rev": "619363c30309d29ffa631e67c8183f2a72caa373", + "src": "https://github.com/stevearc/conform.nvim" + }, + "editorconfig-vim": { + "rev": "13b86c5c691785ffbf2d6508c621dabb08e93df0", + "src": "https://github.com/editorconfig/editorconfig-vim" + }, + "fidget.nvim": { + "rev": "6f793b2bcd2d35e201c09520f698bb763220908a", + "src": "https://github.com/j-hui/fidget.nvim" + }, + "gitsigns.nvim": { + "rev": "eb60cc7b94c46005237fd34170d76f3a089a90aa", + "src": "https://github.com/lewis6991/gitsigns.nvim" + }, + "guess-indent.nvim": { + "rev": "84a4987ff36798c2fc1169cbaff67960aed9776f", + "src": "https://github.com/NMAC427/guess-indent.nvim" + }, + "indent-blankline.nvim": { + "rev": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03", + "src": "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + "kitty-navigator.nvim": { + "rev": "116b88674503edb21481bebdd62212485817fa4a", + "src": "https://github.com/MunsMan/kitty-navigator.nvim" + }, + "lazygit.nvim": { + "rev": "a04ad0dbc725134edbee3a5eea29290976695357", + "src": "https://github.com/kdheepak/lazygit.nvim" + }, + "mason-lspconfig.nvim": { + "rev": "47059d71b42d74b0a1e9f61c1d99d301039c3b5b", + "src": "https://github.com/mason-org/mason-lspconfig.nvim" + }, + "mason-nvim-dap.nvim": { + "rev": "9a10e096703966335bd5c46c8c875d5b0690dade", + "src": "https://github.com/jay-babu/mason-nvim-dap.nvim" + }, + "mason-tool-installer.nvim": { + "rev": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc", + "src": "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" + }, + "mason.nvim": { + "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", + "src": "https://github.com/mason-org/mason.nvim" + }, + "mini.nvim": { + "rev": "c5cdbadeb423ff724e27a42ab2d1c504d1d6fc5a", + "src": "https://github.com/nvim-mini/mini.nvim" + }, + "move.nvim": { + "rev": "599b14047b82e92874b9a408e4df228b965c3a1d", + "src": "https://github.com/fedepujol/move.nvim" + }, + "nvim-bqf": { + "rev": "ba2b365969d7c2c6301d48e13aeee59568765529", + "src": "https://github.com/kevinhwang91/nvim-bqf" + }, + "nvim-colorizer.lua": { + "rev": "81e676d3203c9eb6e4c0ccf1eba1679296ef923f", + "src": "https://github.com/catgoose/nvim-colorizer.lua" + }, + "nvim-dap": { + "rev": "9e848e09a697ee95302a3ef2dd43fd6eb709e570", + "src": "https://github.com/mfussenegger/nvim-dap" + }, + "nvim-dap-go": { + "rev": "b4421153ead5d726603b02743ea40cf26a51ed5f", + "src": "https://github.com/leoluz/nvim-dap-go" + }, + "nvim-dap-ui": { + "rev": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49", + "src": "https://github.com/rcarriga/nvim-dap-ui" + }, + "nvim-lint": { + "rev": "a219b2c9e5b4765e5c845aba119dad55806fcaf1", + "src": "https://github.com/mfussenegger/nvim-lint" + }, + "nvim-lspconfig": { + "rev": "d696e36d5792daf828f8c8e8d4b9aa90c1a10c2a", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-nio": { + "rev": "21f5324bfac14e22ba26553caf69ec76ae8a7662", + "src": "https://github.com/nvim-neotest/nvim-nio" + }, + "nvim-treesitter": { + "rev": "4916d6592ede8c07973490d9322f187e07dfefac", + "src": "https://github.com/nvim-treesitter/nvim-treesitter", + "version": "'main'" + }, + "nvim-web-devicons": { + "rev": "6788013bb9cb784e606ada44206b0e755e4323d7", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "oil.nvim": { + "rev": "756dec855b4811f2d27f067a3aca477f368d99f5", + "src": "https://github.com/stevearc/oil.nvim" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "quick-scope": { + "rev": "6cee1d9e0b9ac0fbffeb538d4a5ba9f5628fabbc", + "src": "https://github.com/unblevable/quick-scope" + }, + "srcery-vim": { + "rev": "38f52babe0fa2b11719b51eb045a85244d6d7883", + "src": "https://github.com/srcery-colors/srcery-vim" + }, + "tabular": { + "rev": "12437cd1b53488e24936ec4b091c9324cafee311", + "src": "https://github.com/godlygeek/tabular" + }, + "telescope-fzf-native.nvim": { + "rev": "b25b749b9db64d375d782094e2b9dce53ad53a40", + "src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + "telescope-ui-select.nvim": { + "rev": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2", + "src": "https://github.com/nvim-telescope/telescope-ui-select.nvim" + }, + "telescope.nvim": { + "rev": "427b576c16792edad01a92b89721d923c19ad60f", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "todo-comments.nvim": { + "rev": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668", + "src": "https://github.com/folke/todo-comments.nvim" + }, + "tokyonight.nvim": { + "rev": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6", + "src": "https://github.com/folke/tokyonight.nvim" + }, + "vim-glsl": { + "rev": "40dd0b143ef93f3930a8a409f60c1bb85e28b727", + "src": "https://github.com/tikhomirov/vim-glsl" + }, + "vim-indent-object": { + "rev": "8ab36d5ec2a3a60468437a95e142ce994df598c6", + "src": "https://github.com/michaeljsmith/vim-indent-object" + }, + "vim-sleuth": { + "rev": "be69bff86754b1aa5adcbb527d7fcd1635a84080", + "src": "https://github.com/tpope/vim-sleuth" + }, + "vim-smoothie": { + "rev": "df1e324e9f3395c630c1c523d0555a01d2eb1b7e", + "src": "https://github.com/psliwka/vim-smoothie" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + } + } +}