├── LICENSE ├── README.md ├── init.lua └── lua ├── plugins ├── bufferline.lua ├── cmp.lua ├── init.lua ├── lsp │ ├── legacy_configs.lua │ └── lua_ls.lua ├── mini.lua ├── nvim-011 │ ├── gitsigns.lua │ ├── lspconfig.lua │ ├── mason-lsp.lua │ ├── mason.lua │ ├── treesitter-textobjects.lua │ └── treesitter.lua ├── nvim-09 │ ├── gitsigns.lua │ ├── lspconfig.lua │ ├── mason-lsp.lua │ ├── mason.lua │ └── treesitter.lua └── snacks.lua └── user ├── commands.lua ├── diagnostics.lua ├── keymaps.lua ├── plugins.lua └── settings.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Heiker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lazy Template 2 | 3 | Base configuration for Neovim. For those looking to make Neovim their new main editor. Here you'll find a popular combination of plugin to make your experience a little bit better. 4 | 5 | A few things have been configured to resemble other modern text editors. You'll find a file explorer with tree style view, list open files in tabs, git integration and a terminal easy to toggle. 6 | 7 | Autocompletion and "code intellisense" is provided by the LSP client built into Neovim. This means if you want smart completion and error detection for a programming language you'll need to install a [language server](#about-language-servers). 8 | 9 | ## Requirements 10 | 11 | * Neovim v0.11 or greater is recommended. 12 | * v0.9.5 is the minimum required. 13 | * git. 14 | * A `C` compiler. Can be `gcc`, `tcc` or `zig`. 15 | * [tree-sitter CLI](https://github.com/tree-sitter/tree-sitter) 0.25 or greater 16 | * (optional) A patched font to display icons. I hear [nerdfonts](https://www.nerdfonts.com/) has a good collection. 17 | * (optional) [ripgrep](https://github.com/BurntSushi/ripgrep). Improves project wide search speed. 18 | * (optional) [fd](https://github.com/sharkdp/fd). Improves file search speed. 19 | 20 | ### Note for windows users 21 | 22 | If you need a `C` compiler then `zig` is the easiest to install. It's available on `winget`, `scoop` and `chocolatey`. You can also find some links in the [zig download page](https://ziglang.org/download/). 23 | 24 | ## Installation 25 | 26 | * Clone this repository in Neovim's configuration folder. 27 | 28 | If you don't know the location of that folder, use this command in your terminal. 29 | 30 | ```sh 31 | nvim --headless -c 'echo stdpath("config") | echo "" | quit' 32 | ``` 33 | 34 | * After you cloned the repository in Neovim's folder, start Neovim using this command in your terminal. 35 | 36 | ```sh 37 | nvim 38 | ``` 39 | 40 | The plugin manager will be installed automatically. And then all the plugins will be installed. 41 | 42 | ## About language servers 43 | 44 | They are external programs that provide IDE-like features to Neovim. If you want to know more about language servers watch this wonderful 5 minutes video: [LSP explained](https://www.youtube.com/watch?v=LaS32vctfOY). 45 | 46 | In this configuration there is a plugin that will help you install language servers: `mason-lspconfig`. If you execute the command `:LspInstall` while you are inside a file then `mason-lspconfig` will suggest a list of language servers that support that particular type of file. 47 | 48 | Keep in mind you need to meet the requirements of the language servers. For example, if you want to download the language server for the `go` programming language then you need to have `go` installed in your system. If you want to download a language server written in javascript you'll need NodeJS. 49 | 50 | ## Learn more about the plugin manager 51 | 52 | `lazy.nvim` is the plugin manager used in this configuration. Here are a few resources that will help you understand some of it's features: 53 | 54 | * [Lazy.nvim: plugin configuration](https://dev.to/vonheikemen/lazynvim-plugin-configuration-3opi). Here you'll learn about the "plugin spec" and how to split your plugin setup into multiple files. 55 | 56 | * [Lazy.nvim: how to revert a plugin back to a previous version](https://dev.to/vonheikemen/lazynvim-how-to-revert-a-plugin-back-to-a-previous-version-1pdp). Learn how to recover from a bad plugin update. 57 | 58 | ## Keybindings 59 | 60 | Leader key: `Space`. 61 | 62 | | Mode | Key | Action | 63 | | --- | --- | --- | 64 | | Normal | `h` | Go to first non empty character in line. | 65 | | Normal | `l` | Go to last non empty character in line. | 66 | | Normal | `a` | Select all text. | 67 | | Normal | `gy` | Copy selected text to clipboard. | 68 | | Normal | `gp` | Paste clipboard content. | 69 | | Normal | `w` | Save file. | 70 | | Normal | `qq` | Exit Neovim. | 71 | | Normal | `bq` | Close current buffer. | 72 | | Normal | `bc` | Close current buffer while preserving the window layout. | 73 | | Normal | `bl` | Go to last active buffer. | 74 | | Normal | `` | Search open buffers. | 75 | | Normal | `ff` | Find file in current working directory. | 76 | | Normal | `fh` | Search oldfiles history. | 77 | | Normal | `fg` | Search pattern in current working directory. | 78 | | Normal | `fd` | Search diagnostics in current file. | 79 | | Normal | `fs` | Search pattern in current file. | 80 | | Normal | `u` | Search undo history. | 81 | | Normal | `?` | Search keymaps. | 82 | | Normal | `/` | Search snack pickers. | 83 | | Normal | `e` | Open file explorer. | 84 | | Normal | `ti` | Toggle indent guide lines. | 85 | | Normal | `` | Toggle a terminal window. | 86 | | Terminal | `` | Pressing `Escape` twice quickly goes back to normal mode. | 87 | | Normal | `gw` | Begin a 2 character jump. | 88 | | Normal | `gcc` | Toggle comment in current line. | 89 | | Operator | `gc` | Toggle comment in text. | 90 | | Operator | `sa` | Add surrounding. | 91 | | Normal | `sd` | Delete surrounding. | 92 | | Normal | `sr` | Surround replace. | 93 | | Normal | `sf` | Find surrounding. | 94 | | Normal | `sb` | Pick a visible tab. | 95 | | Insert | `` | Expand snippet trigger. | 96 | | Insert | `` | Go to previous snippet tabstop. | 97 | | Insert | `` | Go to next snippet tabstop. | 98 | | Normal | `K` | Displays hover information about the symbol under the cursor. | 99 | | Normal | `gd` | Jump to the definition. | 100 | | Normal | `gq` | Format code in current buffer. | 101 | | Normal | `gO` | Lists symbols in the current buffer. | 102 | | Normal | `` | Displays a function's signature information. | 103 | | Normal | `gri` | Lists all the implementations for the symbol under the cursor. | 104 | | Normal | `grr` | Lists all the references. | 105 | | Normal | `grn` | Renames all references to the symbol under the cursor. | 106 | | Normal | `gra` | Selects a code action available at the current cursor position. | 107 | | Normal | `grd` | Jump to declaration. | 108 | | Normal | `grt` | Jumps to the definition of the type symbol | 109 | | Normal | `d` | Show diagnostics in a floating window. | 110 | | Normal | `[b` | Go to the previous buffer. | 111 | | Normal | `]b` | Go to the next buffer. | 112 | | Normal | `[B` | Go to the first buffer. | 113 | | Normal | `]B` | Go to the last buffer. | 114 | | Normal | `[d` | Move cursor to the previous diagnostic. | 115 | | Normal | `]d` | Move cursor to the next diagnostic. | 116 | | Normal | `[q` | Move cursor to the previous location in the quickfix list. | 117 | | Normal | `]q` | Move cursor to the next location in the quickfix list. | 118 | | Normal | `[Q` | Move cursor to the first location in the quickfix list. | 119 | | Normal | `]Q` | Move cursor to the last location in the quickfix list. | 120 | 121 | ### Autocomplete keybindings 122 | 123 | | Mode | Key | Action | 124 | | --- | --- | --- | 125 | | Insert | `` | Move to previous item. | 126 | | Insert | `` | Move to next item. | 127 | | Insert | `` | Move to previous item. | 128 | | Insert | `` | Move to next item. | 129 | | Insert | `` | Scroll up in documentation window. | 130 | | Insert | `` | Scroll down in documentation window. | 131 | | Insert | `` | Cancel completion. | 132 | | Insert | `` | Confirm completion. | 133 | | Insert | `` | Confirm completion. | 134 | | Insert | `` | If completion menu is open, go to next item. Else, open completion menu. | 135 | | Insert | `` | If completion menu is open, go to previous item. | 136 | 137 | ## Plugin list 138 | 139 | | Name | Description | 140 | | --- | --- | 141 | | [lazy.nvim](https://github.com/folke/lazy.nvim) | Plugin manager. | 142 | | [tokyonight.nvim](https://github.com/folke/tokyonight.nvim) | Collection of colorscheme for Neovim. | 143 | | [snacks.nvim](https://github.com/folke/snacks.nvim) | Collection of QoL plugins. | 144 | | [bufferline.nvim](https://github.com/akinsho/bufferline.nvim) | Pretty tabline. | 145 | | [mini.nvim](https://github.com/echasnovski/mini.nvim) | Collection of independent lua modules that enhance Neovim's features. | 146 | | [gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim) | Shows indicators in gutter based on file changes detected by git. | 147 | | [vim-fugitive](https://github.com/tpope/vim-fugitive) | Git integration into Neovim/Vim. | 148 | | [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) | Configures treesitter parsers. Provides modules to manipulate code. | 149 | | [nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects) | Creates textobjects based on treesitter queries. | 150 | | [vim-repeat](https://github.com/tpope/vim-repeat) | Add "repeat" support for plugins. | 151 | | [mason.nvim](https://github.com/williamboman/mason.nvim) | Portable package manager for Neovim. | 152 | | [mason-lspconfig.nvim](https://github.com/williamboman/mason-lspconfig.nvim) | Integrates nvim-lspconfig and mason.nvim. | 153 | | [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) | Quickstart configs for Neovim's LSP client. | 154 | | [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) | Autocompletion engine. | 155 | | [cmp-buffer](https://github.com/hrsh7th/cmp-buffer) | nvim-cmp source. Suggest words in the current buffer. | 156 | | [cmp-path](https://github.com/hrsh7th/cmp-path) | nvim-cmp source. Show suggestions based on file system paths. | 157 | | [cmp-mini-snippets](https://github.com/abeldekat/cmp-mini-snippets) | nvim-cmp source. Show suggestions based on installed snippets. | 158 | | [cmp-nvim-lsp](https://github.com/hrsh7th/cmp-nvim-lsp) | nvim-cmp source. Show suggestions based on LSP servers queries. | 159 | | [friendly-snippets](https://github.com/rafamadriz/friendly-snippets) | Collection of snippets. | 160 | | [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring) | It helps detect comment syntax. | 161 | 162 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | local load = function(mod) 2 | package.loaded[mod] = nil 3 | require(mod) 4 | end 5 | 6 | load('user.settings') 7 | load('user.diagnostics') 8 | load('user.commands') 9 | load('user.keymaps') 10 | require('user.plugins') 11 | 12 | pcall(vim.cmd.colorscheme, 'tokyonight') 13 | 14 | --- 15 | -- Resources: 16 | -- * Learn lua in X minutes 17 | -- https://learnxinyminutes.com/docs/lua/ 18 | -- 19 | -- * Lua crash course (12 min video) 20 | -- https://www.youtube.com/watch?v=NneB6GX1Els 21 | -- 22 | -- * Neovim's official lua guide 23 | -- https://neovim.io/doc/user/lua-guide.html 24 | -- 25 | -- * Lazy.nvim: plugin configuration 26 | -- https://dev.to/vonheikemen/lazynvim-plugin-configuration-3opi 27 | --- 28 | 29 | -------------------------------------------------------------------------------- /lua/plugins/bufferline.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'akinsho/bufferline.nvim'} 2 | 3 | Plugin.opts = { 4 | options = { 5 | mode = 'buffers', 6 | offsets = { 7 | {filetype = 'snacks_layout_box'}, 8 | }, 9 | }, 10 | -- :help bufferline-highlights 11 | highlights = { 12 | buffer_selected = { 13 | italic = false 14 | }, 15 | indicator_selected = { 16 | fg = {attribute = 'fg', highlight = 'Function'}, 17 | italic = false 18 | } 19 | } 20 | } 21 | 22 | function Plugin.init() 23 | vim.keymap.set('n', 'sb', 'BufferLinePick', {desc = 'Pick a visible tab'}) 24 | end 25 | 26 | return Plugin 27 | 28 | -------------------------------------------------------------------------------- /lua/plugins/cmp.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'hrsh7th/nvim-cmp'} 2 | 3 | Plugin.dependencies = { 4 | -- Completion sources 5 | {'hrsh7th/cmp-buffer'}, 6 | {'hrsh7th/cmp-path'}, 7 | {'hrsh7th/cmp-nvim-lsp'}, 8 | {'abeldekat/cmp-mini-snippets'}, 9 | 10 | -- We'll be using mini.snippets 11 | {'echasnovski/mini.nvim'}, 12 | } 13 | 14 | Plugin.event = 'InsertEnter' 15 | 16 | function Plugin.config() 17 | local cmp = require('cmp') 18 | local select_opts = {behavior = cmp.SelectBehavior.Select} 19 | 20 | -- See :help cmp-config 21 | cmp.setup({ 22 | snippet = { 23 | expand = function(args) 24 | require('mini.snippets').default_insert({body = args.body}) 25 | cmp.resubscribe({'TextChangedI', 'TextChangedP'}) 26 | require('cmp.config').set_onetime({sources = {}}) 27 | end 28 | }, 29 | sources = { 30 | {name = 'path'}, 31 | {name = 'nvim_lsp'}, 32 | {name = 'buffer', keyword_length = 3}, 33 | {name = 'mini_snippets', keyword_length = 2}, 34 | }, 35 | window = { 36 | completion = cmp.config.window.bordered(), 37 | documentation = cmp.config.window.bordered(), 38 | }, 39 | -- See :help cmp-mapping 40 | mapping = { 41 | [''] = cmp.mapping.select_prev_item(select_opts), 42 | [''] = cmp.mapping.select_next_item(select_opts), 43 | 44 | [''] = cmp.mapping.select_prev_item(select_opts), 45 | [''] = cmp.mapping.select_next_item(select_opts), 46 | 47 | [''] = cmp.mapping.scroll_docs(-4), 48 | [''] = cmp.mapping.scroll_docs(4), 49 | 50 | [''] = cmp.mapping.abort(), 51 | [''] = cmp.mapping.confirm({select = true}), 52 | [''] = cmp.mapping.confirm({select = false}), 53 | 54 | [''] = cmp.mapping.select_prev_item(select_opts), 55 | 56 | [''] = cmp.mapping(function(fallback) 57 | local col = vim.fn.col('.') - 1 58 | 59 | if cmp.visible() then 60 | cmp.select_next_item(select_opts) 61 | elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then 62 | fallback() 63 | else 64 | cmp.complete() 65 | end 66 | end, {'i', 's'}), 67 | 68 | }, 69 | }) 70 | end 71 | 72 | return Plugin 73 | 74 | -------------------------------------------------------------------------------- /lua/plugins/init.lua: -------------------------------------------------------------------------------- 1 | -- Note: this is where you can add plugins that don't require any configuration. 2 | -- as soon as you need to add options to a plugin consider making a dedicated file. 3 | 4 | local Plugins = { 5 | {'tpope/vim-repeat'}, 6 | {'tpope/vim-fugitive'}, 7 | 8 | -- colorscheme 9 | {'folke/tokyonight.nvim'}, 10 | } 11 | 12 | return Plugins 13 | -------------------------------------------------------------------------------- /lua/plugins/lsp/legacy_configs.lua: -------------------------------------------------------------------------------- 1 | -- Missing legacy configs: 2 | -- https://github.com/neovim/nvim-lspconfig/issues/3705 3 | 4 | return { 5 | 'apex_ls', 6 | 'bqnlsp', 7 | 'cadence', 8 | 'codeqlls', 9 | 'drools_lsp', 10 | 'glint', 11 | 'haxe_language_server', 12 | 'leanls', 13 | 'openedge_ls', 14 | 'relay_lsp', 15 | 'sourcery', 16 | 'vdmj', 17 | 'bitbake_ls', 18 | 'delphi_ls', 19 | } 20 | 21 | -------------------------------------------------------------------------------- /lua/plugins/lsp/lua_ls.lua: -------------------------------------------------------------------------------- 1 | return { 2 | settings = { 3 | Lua = { 4 | workspace = { 5 | checkThirdParty = false 6 | }, 7 | telemetry = { 8 | enable = false 9 | }, 10 | }, 11 | }, 12 | on_init = function(client) 13 | local uv = vim.uv or vim.loop 14 | local join = function(t) return table.concat(t, '/') end 15 | 16 | -- Don't do anything if there is a project local config 17 | if client.workspace_folders then 18 | local path = client.workspace_folders[1].name 19 | local luarc = ( 20 | uv.fs_stat(join({path, '.luarc.json'})) 21 | or uv.fs_stat(join({path, '.luarc.jsonc'})) 22 | ) 23 | 24 | if luarc then 25 | return 26 | end 27 | end 28 | 29 | local nvim_settings = { 30 | runtime = { 31 | -- Tell the language server which version of Lua you're using 32 | version = 'LuaJIT', 33 | path = { 34 | 'lua/?.lua', 35 | 'lua/?/init.lua', 36 | }, 37 | }, 38 | diagnostics = { 39 | -- Get the language server to recognize the `vim` global 40 | globals = {'vim'} 41 | }, 42 | workspace = { 43 | checkThirdParty = false, 44 | library = { 45 | -- Make the server aware of Neovim runtime files 46 | vim.env.VIMRUNTIME, 47 | }, 48 | }, 49 | } 50 | 51 | client.config.settings.Lua = vim.tbl_deep_extend( 52 | 'force', 53 | client.config.settings.Lua, 54 | nvim_settings 55 | ) 56 | end, 57 | } 58 | 59 | -------------------------------------------------------------------------------- /lua/plugins/mini.lua: -------------------------------------------------------------------------------- 1 | -- Note: mini.nvim is a collection of lua modules. 2 | -- each module is basically a standalone plugin. 3 | -- you can read their documentation on github: 4 | -- https://github.com/echasnovski/mini.nvim 5 | 6 | local Plugin = {'echasnovski/mini.nvim'} 7 | local user = {} 8 | 9 | Plugin.lazy = false 10 | 11 | Plugin.dependencies = { 12 | {'rafamadriz/friendly-snippets'}, 13 | { 14 | 'JoosepAlviste/nvim-ts-context-commentstring', 15 | opts = { 16 | enable_autocmd = false, 17 | }, 18 | init = function() 19 | vim.g.skip_ts_context_commentstring_module = true 20 | end, 21 | } 22 | } 23 | 24 | function Plugin.init() 25 | -- Enable "global" statusline 26 | vim.o.laststatus = 3 27 | 28 | -- Don't show current mode below statusline 29 | -- mini.statusline will handle this 30 | vim.o.showmode = false 31 | end 32 | 33 | function Plugin.config() 34 | -- See :help MiniSurround.config 35 | require('mini.surround').setup({}) 36 | 37 | -- See :help MiniAi-textobject-builtin 38 | require('mini.ai').setup({n_lines = 500}) 39 | 40 | -- See :help MiniIcons.config 41 | -- Change style to 'ascii' if you want to disable the fancy icons 42 | require('mini.icons').setup({style = 'glyph'}) 43 | 44 | -- See :help MiniStatusline.config 45 | require('mini.statusline').setup({ 46 | content = {active = user.statusline} 47 | }) 48 | 49 | -- See :help MiniComment.config 50 | require('mini.comment').setup({ 51 | options = { 52 | custom_commentstring = function() 53 | local cs = require('ts_context_commentstring').calculate_commentstring() 54 | return cs or vim.bo.commentstring 55 | end, 56 | }, 57 | }) 58 | 59 | -- See :help MiniNotify.config 60 | require('mini.notify').setup({ 61 | lsp_progress = { 62 | enable = false, 63 | }, 64 | }) 65 | 66 | vim.notify = require('mini.notify').make_notify() 67 | 68 | -- See :help MiniSnippets.config 69 | local mini_snippets = require('mini.snippets') 70 | mini_snippets.setup({ 71 | snippets = { 72 | mini_snippets.gen_loader.from_lang() 73 | } 74 | }) 75 | 76 | -- See :help MiniJump2d.config 77 | require('mini.jump2d').setup({ 78 | allowed_lines = { 79 | blank = false, 80 | fold = false, 81 | }, 82 | allowed_windows = { 83 | not_current = false, 84 | }, 85 | mappings = { 86 | start_jumping = '', 87 | }, 88 | }) 89 | 90 | -- Begin a 2 character jump using mini.jump2d 91 | vim.keymap.set({'n', 'x', 'o'}, 'gw', user.jump_char(), {desc = '2-character jump'}) 92 | 93 | -- See :help MiniClue.config 94 | local clue = user.clues() 95 | require('mini.clue').setup({ 96 | window = { 97 | delay = 600, 98 | config = { 99 | width = 50, 100 | }, 101 | }, 102 | triggers = clue.triggers({ 103 | {mode = 'n', keys = ''}, 104 | {mode = 'x', keys = ''}, 105 | {mode = 'n', keys = 's'}, 106 | {mode = 'x', keys = 's'}, 107 | {mode = 'n', keys = '['}, 108 | {mode = 'n', keys = ']'}, 109 | }), 110 | clues = clue.gen({ 111 | {mode = 'n', keys = '['}, 112 | {mode = 'n', keys = ']'}, 113 | {mode = 'n', keys = 'f', desc = '+Find in files'}, 114 | {mode = 'n', keys = 'b', desc = '+Buffers'}, 115 | }), 116 | }) 117 | end 118 | 119 | -- See :help MiniStatusline-example-content 120 | function user.statusline() 121 | local mini = require('mini.statusline') 122 | local mode, mode_hl = mini.section_mode({trunc_width = 120}) 123 | local diagnostics = mini.section_diagnostics({trunc_width = 75}) 124 | local lsp = mini.section_lsp({icon = 'LSP', trunc_width = 75}) 125 | local filename = mini.section_filename({trunc_width = 140}) 126 | local percent = '%2p%%' 127 | local location = '%3l:%-2c' 128 | 129 | return mini.combine_groups({ 130 | {hl = mode_hl, strings = {mode}}, 131 | {hl = 'MiniStatuslineDevinfo', strings = {diagnostics, lsp}}, 132 | '%<', -- Mark general truncate point 133 | {hl = 'MiniStatuslineFilename', strings = {filename}}, 134 | '%=', -- End left alignment 135 | {hl = 'MiniStatuslineFilename', strings = {'%{&filetype}'}}, 136 | {hl = 'MiniStatuslineFileinfo', strings = {percent}}, 137 | {hl = mode_hl, strings = {location}}, 138 | }) 139 | end 140 | 141 | function user.jump_char() 142 | local opts = {hooks = {}} 143 | local noop = function() return {} end 144 | local spotter = require('mini.jump2d').gen_spotter.pattern 145 | local esc = vim.api.nvim_replace_termcodes('', true, true, true) 146 | 147 | opts.hooks.before_start = function() 148 | local prompt = {{'Chars: '}} 149 | local input = '' 150 | local total = 2 151 | 152 | vim.api.nvim_echo(prompt, false, {}) 153 | 154 | for _=1, total, 1 do 155 | local ok, ch = pcall(vim.fn.getcharstr) 156 | if ok == false or ch == nil or ch == esc then 157 | opts.spotter = noop 158 | return 159 | end 160 | 161 | table.insert(prompt, {ch}) 162 | vim.api.nvim_echo(prompt, false, {}) 163 | 164 | if ch:match('[a-zA-Z]') then 165 | input = string.format('%s[%s%s]', input, ch:lower(), ch:upper()) 166 | else 167 | input = string.format('%s%s', input, vim.pesc(ch)) 168 | end 169 | end 170 | 171 | opts.spotter = spotter(input) 172 | end 173 | 174 | return function() 175 | require('mini.jump2d').start(opts) 176 | end 177 | end 178 | 179 | function user.clues() 180 | local gen = require('mini.clue').gen_clues 181 | local triggers = { 182 | -- Built-in completion 183 | {mode = 'i', keys = ''}, 184 | 185 | -- `g` key 186 | {mode = 'n', keys = 'g'}, 187 | {mode = 'x', keys = 'g'}, 188 | 189 | -- Marks 190 | {mode = 'n', keys = "'"}, 191 | {mode = 'n', keys = '`'}, 192 | {mode = 'x', keys = "'"}, 193 | {mode = 'x', keys = '`'}, 194 | 195 | -- Registers 196 | {mode = 'n', keys = '"'}, 197 | {mode = 'x', keys = '"'}, 198 | {mode = 'i', keys = ''}, 199 | {mode = 'c', keys = ''}, 200 | 201 | -- Window commands 202 | {mode = 'n', keys = ''}, 203 | 204 | -- `z` key 205 | {mode = 'n', keys = 'z'}, 206 | {mode = 'x', keys = 'z'}, 207 | } 208 | 209 | local clues = { 210 | gen.builtin_completion(), 211 | gen.g(), 212 | gen.marks(), 213 | gen.registers(), 214 | gen.windows(), 215 | gen.z(), 216 | } 217 | 218 | local extend = function(list) 219 | return function(opts) 220 | if type(opts) ~= 'table' then 221 | return list 222 | end 223 | 224 | for _, t in ipairs(opts) do 225 | table.insert(list, t) 226 | end 227 | 228 | return list 229 | end 230 | end 231 | 232 | return { 233 | triggers = extend(triggers), 234 | gen = extend(clues) 235 | } 236 | end 237 | 238 | return Plugin 239 | 240 | -------------------------------------------------------------------------------- /lua/plugins/nvim-011/gitsigns.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'lewis6991/gitsigns.nvim'} 2 | 3 | Plugin.event = {'BufReadPre', 'BufNewFile'} 4 | 5 | -- See :help gitsigns-usage 6 | Plugin.opts = { 7 | signs = { 8 | add = {text = '▎'}, 9 | change = {text = '▎'}, 10 | delete = {text = '➤'}, 11 | topdelete = {text = '➤'}, 12 | changedelete = {text = '▎'}, 13 | } 14 | } 15 | 16 | return Plugin 17 | 18 | -------------------------------------------------------------------------------- /lua/plugins/nvim-011/lspconfig.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'neovim/nvim-lspconfig'} 2 | local user = {} 3 | 4 | Plugin.dependencies = { 5 | {'hrsh7th/cmp-nvim-lsp'}, 6 | {'mason-org/mason.nvim'}, 7 | {'mason-org/mason-lspconfig.nvim'}, 8 | } 9 | 10 | Plugin.cmd = {'LspInstall', 'LspUnInstall'} 11 | 12 | Plugin.event = {'BufReadPre', 'BufNewFile'} 13 | 14 | function Plugin.config() 15 | local lspconfig = require('lspconfig') 16 | local group = vim.api.nvim_create_augroup('lsp_cmds', {clear = true}) 17 | 18 | user.lsp_capabilities() 19 | 20 | vim.api.nvim_create_autocmd('LspAttach', { 21 | group = group, 22 | desc = 'LSP actions', 23 | callback = user.on_attach 24 | }) 25 | 26 | local setup = function(server, opts) 27 | if user.legacy_config(server) then 28 | lspconfig[server].setup(opts or {}) 29 | return 30 | end 31 | 32 | if opts then 33 | vim.lsp.config(server, opts) 34 | end 35 | 36 | vim.lsp.enable(server) 37 | end 38 | 39 | local installed_servers = require('mason-lspconfig').get_installed_servers 40 | for _, server in ipairs(installed_servers()) do 41 | local opts = nil 42 | 43 | if server == 'lua_ls' then 44 | -- if you install the language server for lua it will 45 | -- load the config from lua/plugins/lsp/lua_ls.lua 46 | opts = require('plugins.lsp.lua_ls') 47 | end 48 | 49 | setup(server, opts) 50 | end 51 | end 52 | 53 | function user.on_attach(event) 54 | local opts = {buffer = event.buf} 55 | 56 | -- You can search each function in the help page. 57 | -- For example :help vim.lsp.buf.hover() 58 | 59 | vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) 60 | vim.keymap.set('n', 'grt', 'lua vim.lsp.buf.type_definition()', opts) 61 | vim.keymap.set('n', 'grd', 'lua vim.lsp.buf.declaration()', opts) 62 | vim.keymap.set({'n', 'x'}, 'gq', 'lua vim.lsp.buf.format({async = true})', opts) 63 | 64 | vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover({border = "rounded"})', opts) 65 | vim.keymap.set({'i', 's'}, '', 'lua vim.lsp.buf.signature_help({border = "rounded"})', opts) 66 | end 67 | 68 | function user.lsp_capabilities() 69 | local cmp_capabilities = require('cmp_nvim_lsp').default_capabilities() 70 | local lsp_defaults = require('lspconfig').util.default_config 71 | 72 | lsp_defaults.capabilities = vim.tbl_deep_extend( 73 | 'force', 74 | lsp_defaults.capabilities, 75 | cmp_capabilities 76 | ) 77 | 78 | vim.lsp.config('*', {capabilities = cmp_capabilities}) 79 | end 80 | 81 | function user.legacy_config(server) 82 | local configs = require('plugins.lsp.legacy_configs') 83 | return vim.tbl_contains(configs, server) 84 | end 85 | 86 | return Plugin 87 | 88 | -------------------------------------------------------------------------------- /lua/plugins/nvim-011/mason-lsp.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'mason-org/mason-lspconfig.nvim'} 2 | Plugin.lazy = true 3 | 4 | -- See :help mason-lspconfig-settings 5 | Plugin.opts = { 6 | -- language servers will be enabled in 7 | -- lua/plugins/nvim-011/lspconfig.lua 8 | -- that's because lspconfig's migration to vim.lsp.enable() 9 | -- is not 100% complete. See: 10 | -- https://github.com/neovim/nvim-lspconfig/issues/3705 11 | automatic_enable = false, 12 | } 13 | 14 | return Plugin 15 | 16 | -------------------------------------------------------------------------------- /lua/plugins/nvim-011/mason.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'mason-org/mason.nvim'} 2 | 3 | Plugin.lazy = false 4 | 5 | -- See :help mason-settings 6 | Plugin.opts = { 7 | ui = {border = 'rounded'} 8 | } 9 | 10 | return Plugin 11 | 12 | -------------------------------------------------------------------------------- /lua/plugins/nvim-011/treesitter-textobjects.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'nvim-treesitter/nvim-treesitter-textobjects'} 2 | 3 | Plugin.branch = 'main' 4 | Plugin.lazy = false 5 | 6 | function Plugin.config() 7 | local ts_select_mod = require('nvim-treesitter-textobjects.select') 8 | 9 | local keymap = function(lhs, ts_capture) 10 | vim.keymap.set({'x', 'o'}, lhs, function() 11 | ts_select_mod.select_textobject(ts_capture, 'textobjects') 12 | end) 13 | end 14 | 15 | keymap('af', '@function.outer') 16 | keymap('if', '@function.inner') 17 | keymap('ac', '@class.outer') 18 | keymap('ic', '@class.inner') 19 | end 20 | 21 | return Plugin 22 | 23 | -------------------------------------------------------------------------------- /lua/plugins/nvim-011/treesitter.lua: -------------------------------------------------------------------------------- 1 | -- IMPORTANT: tree-sitter CLI is needed 2 | -- https://github.com/tree-sitter/tree-sitter 3 | 4 | local Plugin = {'nvim-treesitter/nvim-treesitter'} 5 | local user = {} 6 | 7 | Plugin.branch = 'main' 8 | Plugin.build = ':TSUpdate' 9 | Plugin.lazy = false 10 | 11 | function Plugin.config() 12 | -- NOTE: the list of supported parsers is the documentation: 13 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/SUPPORTED_LANGUAGES.md 14 | local parsers = {'lua', 'vim', 'vimdoc'} 15 | 16 | local filetypes = user.map_filetypes(parsers) 17 | local group = vim.api.nvim_create_augroup('treesitter_cmds', {clear = true}) 18 | 19 | require('nvim-treesitter').install(parsers) 20 | 21 | vim.api.nvim_create_autocmd('FileType', { 22 | pattern = filetypes, 23 | group = group, 24 | desc = 'enable treesitter syntax highlight', 25 | callback = function() 26 | vim.treesitter.start() 27 | end, 28 | }) 29 | end 30 | 31 | function user.map_filetypes(parsers) 32 | local result = {} 33 | local get_filetypes = vim.treesitter.language.get_filetypes 34 | 35 | for _, parser in ipairs(parsers) do 36 | vim.list_extend(result, get_filetypes(parser)) 37 | end 38 | 39 | return result 40 | end 41 | 42 | return Plugin 43 | 44 | -------------------------------------------------------------------------------- /lua/plugins/nvim-09/gitsigns.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'lewis6991/gitsigns.nvim'} 2 | 3 | Plugin.event = {'BufReadPre', 'BufNewFile'} 4 | 5 | -- Last version that supports Neovim v0.9 6 | Plugin.commit = 'ee28ba3e70ecea811b8f6d7b51d81976e94b121c' 7 | Plugin.pin = true 8 | 9 | -- See :help gitsigns-usage 10 | Plugin.opts = { 11 | signs = { 12 | add = {text = '▎'}, 13 | change = {text = '▎'}, 14 | delete = {text = '➤'}, 15 | topdelete = {text = '➤'}, 16 | changedelete = {text = '▎'}, 17 | } 18 | } 19 | 20 | return Plugin 21 | 22 | -------------------------------------------------------------------------------- /lua/plugins/nvim-09/lspconfig.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'neovim/nvim-lspconfig'} 2 | local user = {} 3 | 4 | Plugin.dependencies = { 5 | {'hrsh7th/cmp-nvim-lsp'}, 6 | {'mason-org/mason.nvim'}, 7 | {'mason-org/mason-lspconfig.nvim'}, 8 | } 9 | 10 | Plugin.cmd = {'LspInfo', 'LspInstall', 'LspUnInstall'} 11 | 12 | Plugin.event = {'BufReadPre', 'BufNewFile'} 13 | 14 | -- Last version that supports Neovim v0.9 15 | Plugin.tag = 'v1.8.0' 16 | Plugin.pin = true 17 | 18 | function Plugin.init() 19 | vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( 20 | vim.lsp.handlers.hover, 21 | {border = 'rounded'} 22 | ) 23 | 24 | vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( 25 | vim.lsp.handlers.signature_help, 26 | {border = 'rounded'} 27 | ) 28 | end 29 | 30 | function Plugin.config() 31 | local lspconfig = require('lspconfig') 32 | local lsp_defaults = lspconfig.util.default_config 33 | local cmp_capabilities = require('cmp_nvim_lsp').default_capabilities() 34 | 35 | lsp_defaults.capabilities = vim.tbl_deep_extend( 36 | 'force', 37 | lsp_defaults.capabilities, 38 | cmp_capabilities 39 | ) 40 | 41 | local group = vim.api.nvim_create_augroup('lsp_cmds', {clear = true}) 42 | 43 | vim.api.nvim_create_autocmd('LspAttach', { 44 | group = group, 45 | desc = 'LSP actions', 46 | callback = user.on_attach 47 | }) 48 | 49 | -- See :help mason-lspconfig-settings 50 | require('mason-lspconfig').setup({ 51 | handlers = { 52 | -- See :help mason-lspconfig-dynamic-server-setup 53 | function(server) 54 | -- See :help lspconfig-setup 55 | lspconfig[server].setup({}) 56 | end, 57 | ['lua_ls'] = function() 58 | -- if you install the language server for lua it will 59 | -- load the config from lua/plugins/lsp/lua_ls.lua 60 | local opts = require('plugins.lsp.lua_ls') 61 | lspconfig.lua_ls.setup(opts) 62 | end 63 | } 64 | }) 65 | end 66 | 67 | function user.on_attach(event) 68 | local opts = {buffer = event.buf} 69 | 70 | -- You can search each function in the help page. 71 | -- For example :help vim.lsp.buf.hover() 72 | 73 | -- These keymaps will become defaults after Neovim v0.11 74 | -- I've added them here for backwards compatibility 75 | vim.keymap.set('n', 'grr', 'lua vim.lsp.buf.references()', opts) 76 | vim.keymap.set('n', 'gri', 'lua vim.lsp.buf.implementation()', opts) 77 | vim.keymap.set('n', 'grn', 'lua vim.lsp.buf.rename()', opts) 78 | vim.keymap.set('n', 'gra', 'lua vim.lsp.buf.code_action()', opts) 79 | vim.keymap.set('n', 'gO', 'lua vim.lsp.buf.document_symbol()', opts) 80 | 81 | -- These are custom keymaps 82 | vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) 83 | vim.keymap.set('n', 'grt', 'lua vim.lsp.buf.type_definition()', opts) 84 | vim.keymap.set('n', 'grd', 'lua vim.lsp.buf.declaration()', opts) 85 | vim.keymap.set({'n', 'x'}, 'gq', 'lua vim.lsp.buf.format({async = true})', opts) 86 | 87 | vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) 88 | vim.keymap.set({'i', 's'}, '', 'lua vim.lsp.buf.signature_help()', opts) 89 | end 90 | 91 | return Plugin 92 | 93 | -------------------------------------------------------------------------------- /lua/plugins/nvim-09/mason-lsp.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'mason-org/mason-lspconfig.nvim'} 2 | 3 | Plugin.lazy = true 4 | Plugin.config = false 5 | 6 | -- Last version that supports Neovim v0.10 7 | Plugin.tag = 'v1.32.0' 8 | Plugin.pin = true 9 | 10 | return Plugin 11 | 12 | -------------------------------------------------------------------------------- /lua/plugins/nvim-09/mason.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'mason-org/mason.nvim'} 2 | 3 | Plugin.lazy = false 4 | 5 | -- Last version that supports Neovim v0.9 6 | Plugin.tag = 'v1.11.0' 7 | Plugin.pin = true 8 | 9 | -- See :help mason-settings 10 | Plugin.opts = { 11 | ui = {border = 'rounded'} 12 | } 13 | 14 | return Plugin 15 | 16 | -------------------------------------------------------------------------------- /lua/plugins/nvim-09/treesitter.lua: -------------------------------------------------------------------------------- 1 | local Plugin = {'nvim-treesitter/nvim-treesitter'} 2 | 3 | Plugin.main = 'nvim-treesitter.configs' 4 | Plugin.tag = 'v0.10.0' 5 | Plugin.pin = true 6 | Plugin.lazy = false 7 | 8 | Plugin.dependencies = { 9 | {'nvim-treesitter/nvim-treesitter-textobjects', branch = 'master'} 10 | } 11 | 12 | Plugin.build = ':TSUpdate' 13 | 14 | -- See :help nvim-treesitter-modules 15 | Plugin.opts = { 16 | auto_install = true, 17 | 18 | highlight = { 19 | enable = true, 20 | }, 21 | 22 | -- :help nvim-treesitter-textobjects-modules 23 | textobjects = { 24 | select = { 25 | enable = true, 26 | lookahead = true, 27 | keymaps = { 28 | ['af'] = '@function.outer', 29 | ['if'] = '@function.inner', 30 | ['ac'] = '@class.outer', 31 | ['ic'] = '@class.inner', 32 | } 33 | }, 34 | }, 35 | 36 | ensure_installed = { 37 | 'lua', 38 | 'vim', 39 | 'vimdoc', 40 | }, 41 | } 42 | 43 | return Plugin 44 | 45 | -------------------------------------------------------------------------------- /lua/plugins/snacks.lua: -------------------------------------------------------------------------------- 1 | -- A collection of QoL plugins for Neovim 2 | local Plugin = {'folke/snacks.nvim'} 3 | 4 | Plugin.lazy = false 5 | 6 | Plugin.opts = { 7 | indent = { 8 | enabled = true, 9 | char = '▏', 10 | }, 11 | scope = { 12 | enabled = false, 13 | }, 14 | toggle = { 15 | notify = false, 16 | }, 17 | input = { 18 | enabled = true, 19 | icon = '❯', 20 | }, 21 | explorer = { 22 | enabled = true, 23 | replace_netrw = true, 24 | }, 25 | picker = { 26 | enabled = true, 27 | formatters = { 28 | file = { 29 | truncate = 78, 30 | }, 31 | }, 32 | }, 33 | bigfile = { 34 | -- Only use `bigfile` module on older Neovim versions 35 | enabled = vim.fn.has('nvim-0.11') == 0, 36 | notify = false, 37 | size = 1024 * 1024, -- 1MB 38 | setup = function(ctx) 39 | vim.cmd('syntax clear') 40 | vim.opt_local.syntax = 'OFF' 41 | local buf = vim.b[ctx.buf] 42 | if buf.ts_highlight then 43 | vim.treesitter.stop(ctx.buf) 44 | end 45 | end 46 | }, 47 | } 48 | 49 | function Plugin.config(_, opts) 50 | -- Disable indent guide animation 51 | vim.g.snacks_animate = false 52 | 53 | local Snacks = require('snacks') 54 | Snacks.setup(opts) 55 | 56 | -- Note: to learn the keymaps available inside a snack picker go to 57 | -- normal mode and press `?` to display the help window. 58 | -- Sadly, the help window will fail on Neovim v0.9.5 59 | 60 | -- File explorer 61 | -- docs: https://github.com/folke/snacks.nvim/blob/main/docs/explorer.md 62 | -- Note: this explorer is also a "snack picker" 63 | vim.keymap.set('n', 'e', 'lua Snacks.explorer()', {desc = 'File explorer'}) 64 | 65 | -- Fuzzy finders 66 | -- docs: https://github.com/folke/snacks.nvim/blob/main/docs/picker.md 67 | vim.keymap.set('n', '', 'lua Snacks.picker("buffers")', {desc = 'Search open files'}) 68 | vim.keymap.set('n', 'ff', 'lua Snacks.picker("files")', {desc = 'Search all files'}) 69 | vim.keymap.set('n', 'fh', 'lua Snacks.picker("recent")', {desc = 'Search file history'}) 70 | vim.keymap.set('n', 'fg', 'lua Snacks.picker("grep")', {desc = 'Search in project'}) 71 | vim.keymap.set('n', 'fd', 'lua Snacks.picker("diagnostics")', {desc = 'Search diagnostics'}) 72 | vim.keymap.set('n', 'fs', 'lua Snacks.picker("lines")', {desc = 'Buffer local search'}) 73 | vim.keymap.set('n', 'u', 'lua Snacks.picker("undo")', {desc = 'Undo history'}) 74 | vim.keymap.set('n', '/', 'lua Snacks.picker("pickers")', {desc = 'Search picker'}) 75 | vim.keymap.set('n', '?', 'lua Snacks.picker("keymaps")', {desc = 'Search keymaps'}) 76 | 77 | -- Toggle terminal window 78 | -- docs: https://github.com/folke/snacks.nvim/blob/main/docs/terminal.md 79 | vim.keymap.set({'n', 't'}, '', 'lua Snacks.terminal.toggle()', {desc = 'Toggle terminal'}) 80 | 81 | -- Close buffer while preserving window layout 82 | -- docs: https://github.com/folke/snacks.nvim/blob/main/docs/bufdelete.md 83 | vim.keymap.set('n', 'bc', 'lua Snacks.bufdelete()', {desc = 'Close buffer'}) 84 | 85 | -- Toggle indent guide lines 86 | vim.keymap.set('n', 'ti', 'lua Snacks.toggle.indent():toggle()', {desc = 'Toggle indent guides'}) 87 | end 88 | 89 | return Plugin 90 | 91 | -------------------------------------------------------------------------------- /lua/user/commands.lua: -------------------------------------------------------------------------------- 1 | local group = vim.api.nvim_create_augroup('user_cmds', {clear = true}) 2 | 3 | vim.api.nvim_create_user_command('ReloadConfig', 'source $MYVIMRC', {}) 4 | 5 | vim.api.nvim_create_user_command( 6 | 'TrailspaceTrim', 7 | function() 8 | -- Save cursor position to later restore 9 | local curpos = vim.api.nvim_win_get_cursor(0) 10 | 11 | -- Search and replace trailing whitespace 12 | vim.cmd([[keeppatterns %s/\s\+$//e]]) 13 | vim.api.nvim_win_set_cursor(0, curpos) 14 | end, 15 | {desc = 'Delete extra whitespace'} 16 | ) 17 | 18 | vim.api.nvim_create_autocmd('TextYankPost', { 19 | desc = 'Highlight on yank', 20 | group = group, 21 | callback = function() 22 | vim.highlight.on_yank({higroup = 'Visual', timeout = 200}) 23 | end, 24 | }) 25 | 26 | vim.api.nvim_create_autocmd('FileType', { 27 | pattern = {'help', 'man'}, 28 | group = group, 29 | command = 'nnoremap q close' 30 | }) 31 | 32 | -------------------------------------------------------------------------------- /lua/user/diagnostics.lua: -------------------------------------------------------------------------------- 1 | local levels = vim.diagnostic.severity 2 | local opts = { 3 | virtual_text = true, 4 | float = { 5 | border = 'rounded', 6 | }, 7 | signs = { 8 | text = { 9 | [levels.ERROR] = '✘', 10 | [levels.WARN] = '▲', 11 | [levels.HINT] = '⚑', 12 | [levels.INFO] = '»', 13 | }, 14 | }, 15 | } 16 | 17 | local function sign_define(name, text) 18 | local hl = 'DiagnosticSign' .. name 19 | vim.fn.sign_define(hl, { 20 | texthl = hl, 21 | text = text, 22 | numhl = '' 23 | }) 24 | end 25 | 26 | -- Ensure compatiblity with older Neovim versions 27 | if vim.fn.has('nvim-0.11') == 0 then 28 | sign_define('Error', opts.signs.text[levels.ERROR]) 29 | sign_define('Warn', opts.signs.text[levels.WARN]) 30 | sign_define('Hint', opts.signs.text[levels.HINT]) 31 | sign_define('Info', opts.signs.text[levels.INFO]) 32 | 33 | vim.keymap.set('n', 'd', 'lua vim.diagnostic.open_float()') 34 | vim.keymap.set('n', '', 'lua vim.diagnostic.open_float()') 35 | vim.keymap.set('n', '[d', 'lua vim.diagnostic.goto_prev()') 36 | vim.keymap.set('n', ']d', 'lua vim.diagnostic.goto_next()') 37 | end 38 | 39 | vim.diagnostic.config(opts) 40 | 41 | -------------------------------------------------------------------------------- /lua/user/keymaps.lua: -------------------------------------------------------------------------------- 1 | -- Space as leader key 2 | vim.g.mapleader = ' ' 3 | 4 | -- Shortcuts 5 | vim.keymap.set({'n', 'x', 'o'}, 'h', '^', {desc = 'Go to first non-blank character'}) 6 | vim.keymap.set({'n', 'x', 'o'}, 'l', 'g_', {desc = 'Go to last non-blank character'}) 7 | vim.keymap.set('n', 'a', ':keepjumps normal! ggVG', {desc = 'Select all text'}) 8 | 9 | -- Basic clipboard interaction 10 | vim.keymap.set({'n', 'x'}, 'gy', '"+y', {desc = 'Copy to clipboard'}) 11 | vim.keymap.set({'n', 'x'}, 'gp', '"+p', {desc = 'Paste clipboard content'}) 12 | 13 | -- Delete text without changing vim's internal registers 14 | vim.keymap.set({'n', 'x'}, 'x', '"_x', {desc = 'Cut character'}) 15 | vim.keymap.set({'n', 'x'}, 'X', '"_d', {desc = 'Cut text'}) 16 | 17 | -- Commands 18 | vim.keymap.set('n', 'w', 'write', {desc = 'Save buffer'}) 19 | vim.keymap.set('n', 'qq', 'quitall', {desc = 'Exit Neovim'}) 20 | vim.keymap.set('n', 'bq', 'bdelete', {desc = 'Close buffer and window'}) 21 | vim.keymap.set('n', 'bl', 'buffer #', {desc = 'Go to last active buffer'}) 22 | 23 | if vim.fn.has('nvim-0.11') == 0 then 24 | -- navigate between open buffers 25 | vim.keymap.set('n', '[b', 'bprevious', {desc = ':bprevious'}) 26 | vim.keymap.set('n', ']b', 'bnext', {desc = ':bnext'}) 27 | vim.keymap.set('n', '[B', 'brewind', {desc = ':brewind'}) 28 | vim.keymap.set('n', ']B', 'blast', {desc = ':blast'}) 29 | 30 | -- navigate the quickfix list 31 | vim.keymap.set('n', '[q', 'cprevious', {desc = ':cprevious'}) 32 | vim.keymap.set('n', ']q', 'cnext', {desc = ':cnext'}) 33 | vim.keymap.set('n', '[Q', 'crewind', {desc = ':crewind'}) 34 | vim.keymap.set('n', ']Q', 'clast', {desc = ':clast'}) 35 | end 36 | 37 | -------------------------------------------------------------------------------- /lua/user/plugins.lua: -------------------------------------------------------------------------------- 1 | local lazy = {} 2 | 3 | function lazy.install(path) 4 | local uv = vim.uv or vim.loop 5 | if not uv.fs_stat(path) then 6 | print('Installing lazy.nvim....') 7 | vim.fn.system({ 8 | 'git', 9 | 'clone', 10 | '--filter=blob:none', 11 | 'https://github.com/folke/lazy.nvim.git', 12 | '--branch=stable', -- latest stable release 13 | path, 14 | }) 15 | print('Done.') 16 | end 17 | end 18 | 19 | function lazy.setup(plugins) 20 | -- You can "comment out" the line below after lazy.nvim is installed 21 | lazy.install(lazy.path) 22 | 23 | vim.opt.rtp:prepend(lazy.path) 24 | 25 | require('lazy').setup(plugins, lazy.opts) 26 | end 27 | 28 | lazy.path = table.concat({ 29 | vim.fn.stdpath('data') --[[@as string]], 30 | 'lazy', 31 | 'lazy.nvim' 32 | }, '/') 33 | 34 | lazy.opts = { 35 | ui = { 36 | border = 'rounded', 37 | }, 38 | install = { 39 | missing = true, -- install missing plugins on startup. 40 | }, 41 | change_detection = { 42 | enabled = false, -- check for config file changes 43 | notify = false, -- get a notification when changes are found 44 | }, 45 | } 46 | 47 | -- include all configurations from lua/plugins/* folder 48 | -- note: files in nested folders are not included by default (which is good) 49 | local plugins = {{import = 'plugins'}} 50 | 51 | if vim.fn.has('nvim-0.11') == 1 then 52 | -- include plugins in lua/plugins/nvim-011/* 53 | -- these are not compatible with older versions of neovim 54 | table.insert(plugins, {import = 'plugins.nvim-011'}) 55 | else 56 | -- include plugins in lua/plugins/nvim-09/* 57 | -- these are pinned to a version that still work on nvim v0.9 and v0.10 58 | table.insert(plugins, {import = 'plugins.nvim-09'}) 59 | end 60 | 61 | lazy.setup(plugins) 62 | 63 | -------------------------------------------------------------------------------- /lua/user/settings.lua: -------------------------------------------------------------------------------- 1 | -- You can read the description of each option in the help page 2 | -- use :help 'option_name' command 3 | -- For example, :help 'hlsearch' 4 | 5 | vim.o.number = true 6 | vim.o.mouse = 'a' 7 | vim.o.ignorecase = true 8 | vim.o.smartcase = true 9 | vim.o.hlsearch = false 10 | vim.o.wrap = false 11 | vim.o.tabstop = 2 12 | vim.o.shiftwidth = 2 13 | vim.o.expandtab = false 14 | vim.o.signcolumn = 'yes' 15 | vim.o.termguicolors = true 16 | 17 | --------------------------------------------------------------------------------