diff options
Diffstat (limited to 'vim/kickstarter.lua')
-rw-r--r-- | vim/kickstarter.lua | 799 |
1 files changed, 0 insertions, 799 deletions
diff --git a/vim/kickstarter.lua b/vim/kickstarter.lua deleted file mode 100644 index 1805fa2..0000000 --- a/vim/kickstarter.lua +++ /dev/null | |||
@@ -1,799 +0,0 @@ | |||
1 | --[[ | ||
2 | |||
3 | ===================================================================== | ||
4 | ==================== READ THIS BEFORE CONTINUING ==================== | ||
5 | ===================================================================== | ||
6 | ======== .-----. ======== | ||
7 | ======== .----------------------. | === | ======== | ||
8 | ======== |.-""""""""""""""""""-.| |-----| ======== | ||
9 | ======== || || | === | ======== | ||
10 | ======== || KICKSTART.NVIM || |-----| ======== | ||
11 | ======== || || | === | ======== | ||
12 | ======== || || |-----| ======== | ||
13 | ======== ||:Tutor || |:::::| ======== | ||
14 | ======== |'-..................-'| |____o| ======== | ||
15 | ======== `"")----------------(""` ___________ ======== | ||
16 | ======== /::::::::::| |::::::::::\ \ no mouse \ ======== | ||
17 | ======== /:::========| |==hjkl==:::\ \ required \ ======== | ||
18 | ======== '""""""""""""' '""""""""""""' '""""""""""' ======== | ||
19 | ======== ======== | ||
20 | ===================================================================== | ||
21 | ===================================================================== | ||
22 | |||
23 | What is Kickstart? | ||
24 | |||
25 | Kickstart.nvim is *not* a distribution. | ||
26 | |||
27 | Kickstart.nvim is a starting point for your own configuration. | ||
28 | The goal is that you can read every line of code, top-to-bottom, understand | ||
29 | what your configuration is doing, and modify it to suit your needs. | ||
30 | |||
31 | Once you've done that, you can start exploring, configuring and tinkering to | ||
32 | make Neovim your own! That might mean leaving Kickstart just the way it is for a while | ||
33 | or immediately breaking it into modular pieces. It's up to you! | ||
34 | |||
35 | If you don't know anything about Lua, I recommend taking some time to read through | ||
36 | a guide. One possible example which will only take 10-15 minutes: | ||
37 | - https://learnxinyminutes.com/docs/lua/ | ||
38 | |||
39 | After understanding a bit more about Lua, you can use `:help lua-guide` as a | ||
40 | reference for how Neovim integrates Lua. | ||
41 | - :help lua-guide | ||
42 | - (or HTML version): https://neovim.io/doc/user/lua-guide.html | ||
43 | |||
44 | Kickstart Guide: | ||
45 | |||
46 | TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. | ||
47 | |||
48 | If you don't know what this means, type the following: | ||
49 | - <escape key> | ||
50 | - : | ||
51 | - Tutor | ||
52 | - <enter key> | ||
53 | |||
54 | (If you already know the Neovim basics, you can skip this step.) | ||
55 | |||
56 | Once you've completed that, you can continue working through **AND READING** the rest | ||
57 | of the kickstart init.lua. | ||
58 | |||
59 | Next, run AND READ `:help`. | ||
60 | This will open up a help window with some basic information | ||
61 | about reading, navigating and searching the builtin help documentation. | ||
62 | |||
63 | This should be the first place you go to look when you're stuck or confused | ||
64 | with something. It's one of my favorite Neovim features. | ||
65 | |||
66 | MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation, | ||
67 | which is very useful when you're not exactly sure of what you're looking for. | ||
68 | |||
69 | I have left several `:help X` comments throughout the init.lua | ||
70 | These are hints about where to find more information about the relevant settings, | ||
71 | plugins or Neovim features used in Kickstart. | ||
72 | |||
73 | NOTE: Look for lines like this | ||
74 | |||
75 | Throughout the file. These are for you, the reader, to help you understand what is happening. | ||
76 | Feel free to delete them once you know what you're doing, but they should serve as a guide | ||
77 | for when you are first encountering a few different constructs in your Neovim config. | ||
78 | |||
79 | If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. | ||
80 | |||
81 | I hope you enjoy your Neovim journey, | ||
82 | - TJ | ||
83 | |||
84 | P.S. You can delete this when you're done too. It's your config now! :) | ||
85 | --]] | ||
86 | |||
87 | -- Install package manager | ||
88 | -- https://github.com/folke/lazy.nvim | ||
89 | -- `:help lazy.nvim.txt` for more info | ||
90 | local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' | ||
91 | if not vim.loop.fs_stat(lazypath) then | ||
92 | vim.fn.system { | ||
93 | 'git', | ||
94 | 'clone', | ||
95 | '--filter=blob:none', | ||
96 | 'https://github.com/folke/lazy.nvim.git', | ||
97 | '--branch=stable', -- latest stable release | ||
98 | lazypath, | ||
99 | } | ||
100 | end | ||
101 | vim.opt.runtimepath:prepend(lazypath) | ||
102 | |||
103 | -- NOTE: Here is where you install your plugins. | ||
104 | -- You can configure plugins using the `config` key. | ||
105 | -- | ||
106 | -- You can also configure plugins after the setup call, | ||
107 | -- as they will be available in your neovim runtime. | ||
108 | require('lazy').setup({ | ||
109 | -- NOTE: First, some plugins that don't require any configuration | ||
110 | -- Git related plugins | ||
111 | 'tpope/vim-fugitive', | ||
112 | 'tpope/vim-rhubarb', | ||
113 | |||
114 | -- Detect tabstop and shiftwidth automatically | ||
115 | 'tpope/vim-sleuth', | ||
116 | |||
117 | -- Use sudo in command mode | ||
118 | 'lambdalisue/suda.vim', | ||
119 | |||
120 | -- For beancount | ||
121 | 'nathangrigg/vim-beancount', | ||
122 | |||
123 | -- For surrounding | ||
124 | 'tpope/vim-surround', | ||
125 | |||
126 | |||
127 | -- From vim plugin | ||
128 | 'junegunn/goyo.vim', | ||
129 | 'itchyny/lightline.vim', | ||
130 | 'preservim/nerdtree', | ||
131 | |||
132 | { | ||
133 | -- onedark.nvim: Theme inspired by Atom | ||
134 | 'navarasu/onedark.nvim', | ||
135 | priority = 1000, | ||
136 | config = function() | ||
137 | vim.cmd.colorscheme 'onedark' | ||
138 | -- vim.cmd('source ~/.vim/vim-init/init/init-basic.vim') | ||
139 | end, | ||
140 | }, | ||
141 | |||
142 | -- hop.nvim | ||
143 | { | ||
144 | 'smoka7/hop.nvim', | ||
145 | version = "*", | ||
146 | opts = { | ||
147 | keys = 'etovxqpdygfblzhckisuran' | ||
148 | } | ||
149 | }, | ||
150 | { | ||
151 | "epwalsh/obsidian.nvim", | ||
152 | version = "*", -- recommended, use latest release instead of latest commit | ||
153 | lazy = true, | ||
154 | ft = "markdown", | ||
155 | -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: | ||
156 | -- event = { | ||
157 | -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. | ||
158 | -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" | ||
159 | -- "BufReadPre path/to/my-vault/**.md", | ||
160 | -- "BufNewFile path/to/my-vault/**.md", | ||
161 | -- }, | ||
162 | dependencies = { | ||
163 | -- Required. | ||
164 | "nvim-lua/plenary.nvim", | ||
165 | |||
166 | -- see below for full list of optional dependencies 👇 | ||
167 | }, | ||
168 | opts = { | ||
169 | workspaces = { | ||
170 | { | ||
171 | name = "log", | ||
172 | path = "~/log", | ||
173 | }, | ||
174 | }, | ||
175 | completion = { | ||
176 | -- Set to false to disable completion. | ||
177 | nvim_cmp = true, | ||
178 | -- Trigger completion at 2 chars. | ||
179 | min_chars = 2, | ||
180 | }, | ||
181 | mapping = { | ||
182 | -- Toggle check-boxes. | ||
183 | ["<leader>oc"] = { | ||
184 | action = function() | ||
185 | return require("obsidian").util.toggle_checkbox() | ||
186 | end, | ||
187 | opts = { buffer = true }, | ||
188 | }, | ||
189 | -- Smart action depending on context, either follow link or toggle checkbox. | ||
190 | ["<cr>"] = { | ||
191 | action = function() | ||
192 | return require("obsidian").util.smart_action() | ||
193 | end, | ||
194 | opts = { buffer = true, expr = true }, | ||
195 | } | ||
196 | }, | ||
197 | -- see below for full list of options 👇 | ||
198 | note_id_func = function(title) | ||
199 | return title | ||
200 | -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. | ||
201 | -- In this case a note with the title 'My new note' will be given an ID that looks | ||
202 | -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' | ||
203 | -- local suffix = "" | ||
204 | -- title = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() | ||
205 | -- if title ~= nil and title ~= "" then | ||
206 | -- -- If title is given, transform it into valid file name. | ||
207 | -- suffix = "-" .. title | ||
208 | -- else | ||
209 | -- -- If title is nil, just add 4 random uppercase letters to the suffix. | ||
210 | -- for _ = 1, 4 do | ||
211 | -- suffix = suffix .. string.char(math.random(65, 90)) | ||
212 | -- end | ||
213 | -- suffix = "-" .. title | ||
214 | -- end | ||
215 | -- return tostring(os.time()) .. suffix | ||
216 | end, | ||
217 | }, | ||
218 | }, | ||
219 | |||
220 | -- NOTE: This is where your plugins related to LSP can be installed. | ||
221 | -- The configuration is done below. Search for lspconfig to find it below. | ||
222 | { | ||
223 | -- LSP Configuration & Plugins | ||
224 | 'neovim/nvim-lspconfig', | ||
225 | dependencies = { | ||
226 | -- Automatically install LSPs to stdpath for neovim | ||
227 | { 'williamboman/mason.nvim', config = true }, | ||
228 | 'williamboman/mason-lspconfig.nvim', | ||
229 | |||
230 | -- Useful status updates for LSP | ||
231 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` | ||
232 | { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, | ||
233 | |||
234 | -- Additional lua configuration, makes nvim stuff amazing! | ||
235 | 'folke/neodev.nvim', | ||
236 | }, | ||
237 | }, | ||
238 | |||
239 | { | ||
240 | -- Autocompletion | ||
241 | 'hrsh7th/nvim-cmp', | ||
242 | dependencies = { | ||
243 | -- Snippet Engine & its associated nvim-cmp source | ||
244 | 'L3MON4D3/LuaSnip', | ||
245 | 'saadparwaiz1/cmp_luasnip', | ||
246 | |||
247 | -- Adds LSP completion capabilities | ||
248 | 'hrsh7th/cmp-nvim-lsp', | ||
249 | |||
250 | -- Adds a number of user-friendly snippets | ||
251 | 'rafamadriz/friendly-snippets', | ||
252 | }, | ||
253 | }, | ||
254 | |||
255 | -- Useful plugin to show you pending keybinds. | ||
256 | { | ||
257 | 'folke/which-key.nvim', | ||
258 | opts = { | ||
259 | plugins = { | ||
260 | spelling = { | ||
261 | enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions | ||
262 | suggestions = 20, -- how many suggestions should be shown in the list? | ||
263 | }, | ||
264 | } | ||
265 | } | ||
266 | }, | ||
267 | { | ||
268 | -- Adds git related signs to the gutter, as well as utilities for managing changes | ||
269 | 'lewis6991/gitsigns.nvim', | ||
270 | opts = { | ||
271 | -- See `:help gitsigns.txt` | ||
272 | signs = { | ||
273 | add = { text = '+' }, | ||
274 | change = { text = '~' }, | ||
275 | delete = { text = '_' }, | ||
276 | topdelete = { text = '‾' }, | ||
277 | changedelete = { text = '~' }, | ||
278 | }, | ||
279 | on_attach = function(bufnr) | ||
280 | vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, | ||
281 | { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) | ||
282 | vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) | ||
283 | vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) | ||
284 | vim.keymap.set('n', '<leader>hd', require('gitsigns').diffthis) | ||
285 | vim.keymap.set('n', '<leader>hD', function() require('gitsigns').diffthis('~') end) | ||
286 | end, | ||
287 | }, | ||
288 | }, | ||
289 | { | ||
290 | 'stevearc/aerial.nvim', | ||
291 | enable = false, | ||
292 | opts = {}, | ||
293 | -- Optional dependencies | ||
294 | dependencies = { | ||
295 | "nvim-treesitter/nvim-treesitter", | ||
296 | "nvim-tree/nvim-web-devicons" | ||
297 | }, | ||
298 | }, | ||
299 | |||
300 | |||
301 | --{ | ||
302 | -- -- Set lualine as statusline | ||
303 | -- 'nvim-lualine/lualine.nvim', | ||
304 | -- -- See `:help lualine.txt` | ||
305 | -- opts = { | ||
306 | -- options = { | ||
307 | -- icons_enabled = false, | ||
308 | -- theme = 'onedark', | ||
309 | -- component_separators = '|', | ||
310 | -- section_separators = { left = 'î‚´', right = '' }, | ||
311 | -- }, | ||
312 | -- }, | ||
313 | --}, | ||
314 | |||
315 | { | ||
316 | -- Add indentation guides even on blank lines | ||
317 | 'lukas-reineke/indent-blankline.nvim', | ||
318 | -- Enable `lukas-reineke/indent-blankline.nvim` | ||
319 | -- See `:help ibl` | ||
320 | main = "ibl", | ||
321 | opts = { | ||
322 | indent = { char = "┊" }, | ||
323 | whitespace = { highlight = { "Whitespace", "NonText" } }, | ||
324 | }, | ||
325 | }, | ||
326 | |||
327 | -- "gc" to comment visual regions/lines | ||
328 | --{ 'numToStr/Comment.nvim', opts = {} }, | ||
329 | -- Another config | ||
330 | { | ||
331 | 'numToStr/Comment.nvim', | ||
332 | opts = { | ||
333 | opleader = { | ||
334 | ---Line-comment keymap | ||
335 | line = '<C-/>', | ||
336 | ---Block-comment keymap | ||
337 | block = 'gb', | ||
338 | }, | ||
339 | } | ||
340 | }, | ||
341 | |||
342 | |||
343 | -- Fuzzy Finder (files, lsp, etc) | ||
344 | { | ||
345 | 'nvim-telescope/telescope.nvim', | ||
346 | branch = '0.1.x', | ||
347 | dependencies = { | ||
348 | 'nvim-lua/plenary.nvim', | ||
349 | -- Fuzzy Finder Algorithm which requires local dependencies to be built. | ||
350 | -- Only load if `make` is available. Make sure you have the system | ||
351 | -- requirements installed. | ||
352 | { | ||
353 | 'nvim-telescope/telescope-fzf-native.nvim', | ||
354 | -- NOTE: If you are having trouble with this installation, | ||
355 | -- refer to the README for telescope-fzf-native for more instructions. | ||
356 | build = 'make', | ||
357 | cond = function() | ||
358 | return vim.fn.executable 'make' == 1 | ||
359 | end, | ||
360 | }, | ||
361 | }, | ||
362 | }, | ||
363 | |||
364 | { | ||
365 | -- Highlight, edit, and navigate code | ||
366 | 'nvim-treesitter/nvim-treesitter', | ||
367 | dependencies = { | ||
368 | 'nvim-treesitter/nvim-treesitter-textobjects', | ||
369 | }, | ||
370 | build = ':TSUpdate', | ||
371 | }, | ||
372 | |||
373 | -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart | ||
374 | -- These are some example plugins that I've included in the kickstart repository. | ||
375 | -- Uncomment any of the lines below to enable them. | ||
376 | -- require 'kickstart.plugins.autoformat', | ||
377 | -- require 'kickstart.plugins.debug', | ||
378 | |||
379 | -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` | ||
380 | -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping | ||
381 | -- up-to-date with whatever is in the kickstart repo. | ||
382 | -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. | ||
383 | -- | ||
384 | -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins | ||
385 | -- { import = 'custom.plugins' }, | ||
386 | -- install without yarn or npm | ||
387 | { | ||
388 | "iamcco/markdown-preview.nvim", | ||
389 | cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, | ||
390 | ft = { "markdown" }, | ||
391 | build = function() vim.fn["mkdp#util#install"]() end, | ||
392 | }, | ||
393 | }, {}) | ||
394 | |||
395 | -- [[ Setting options ]] | ||
396 | -- See `:help vim.o` | ||
397 | |||
398 | -- Sync clipboard between OS and Neovim. | ||
399 | -- Remove this option if you want your OS clipboard to remain independent. | ||
400 | -- See `:help 'clipboard'` | ||
401 | |||
402 | -- vim.o.clipboard = 'unnamedplus' | ||
403 | |||
404 | -- Let cursor be line in insert mode | ||
405 | vim.opt.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" | ||
406 | |||
407 | -- Enable break indent | ||
408 | vim.o.breakindent = true | ||
409 | |||
410 | -- Save undo history | ||
411 | vim.o.undofile = true | ||
412 | |||
413 | -- Case-insensitive searching UNLESS \C or capital in search | ||
414 | vim.o.ignorecase = true | ||
415 | vim.o.smartcase = true | ||
416 | |||
417 | -- Keep signcolumn on by default | ||
418 | vim.wo.signcolumn = 'yes' | ||
419 | |||
420 | -- Decrease update time | ||
421 | vim.o.updatetime = 250 | ||
422 | vim.o.timeout = true | ||
423 | vim.o.timeoutlen = 300 | ||
424 | |||
425 | -- Set completeopt to have a better completion experience | ||
426 | vim.o.completeopt = 'menuone,noselect' | ||
427 | |||
428 | -- NOTE: You should make sure your terminal supports this | ||
429 | vim.o.termguicolors = true | ||
430 | |||
431 | -- [[ Basic Keymaps ]] | ||
432 | |||
433 | -- Keymaps for better default experience | ||
434 | -- See `:help vim.keymap.set()` | ||
435 | -- vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) | ||
436 | |||
437 | -- Use suda.vim to run sudo, or terminal prompt fails | ||
438 | -- See more details at https://github.com/neovim/neovim/issue | ||
439 | vim.cmd("command! W execute 'SudaWrite %'") | ||
440 | |||
441 | -- [[ Configure vim.surround ]] | ||
442 | vim.cmd('vmap s S') | ||
443 | |||
444 | -- [[ Configure lualine ]] | ||
445 | -- Change the background of lualine_b section for normal mode | ||
446 | -- local custom_wombat = require 'lualine.themes.wombat' | ||
447 | -- custom_wombat.normal.b.bg = '#a8a8a8' | ||
448 | -- custom_wombat.normal.b.fg = '#444444' | ||
449 | -- require('lualine').setup { | ||
450 | -- options = { theme = custom_wombat }, | ||
451 | -- } | ||
452 | |||
453 | -- [[ Configure lightline ]] | ||
454 | vim.cmd("let g:lightline = { 'colorscheme': 'wombat' }") | ||
455 | |||
456 | -- [[ Configure Goyo ]] | ||
457 | vim.cmd("nnoremap <silent> <leader>z :Goyo<CR>") | ||
458 | |||
459 | -- [[ Configure NERDTree ]] | ||
460 | vim.g.NERDTreeWinPos = 'left' | ||
461 | vim.g.NERDTreeShowHidden = 0 | ||
462 | vim.api.nvim_set_var('NERDTreeWinSize', 35) | ||
463 | vim.cmd("map <C-n> :NERDTreeToggle<cr>") | ||
464 | vim.cmd("map <leader>nb :NERDTreeFromBookmark<Space>") | ||
465 | vim.cmd("map <leader>nf :NERDTreeFind<cr>") | ||
466 | vim.o.autochdir = 0 | ||
467 | -- vim.cmd("autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif") | ||
468 | |||
469 | -- [ Configure Hop ] | ||
470 | vim.keymap.set('n', "<space>", ':HopWord<CR>') | ||
471 | vim.keymap.set('n', '<C-.>', ':HopChar1<CR>') | ||
472 | |||
473 | -- [[ Highlight on yank ]] | ||
474 | -- See `:help vim.highlight.on_yank()` | ||
475 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) | ||
476 | vim.api.nvim_create_autocmd('TextYankPost', { | ||
477 | callback = function() | ||
478 | vim.highlight.on_yank() | ||
479 | end, | ||
480 | group = highlight_group, | ||
481 | pattern = '*', | ||
482 | }) | ||
483 | |||
484 | -- [[ Configure Comment.nvim ]] | ||
485 | vim.cmd('nmap <C-/> V<C-/>') | ||
486 | |||
487 | -- [[ Configure Comment.nvim ]] | ||
488 | vim.keymap.set('n', "<leader>oo", ':Obsidian') | ||
489 | vim.keymap.set('n', "<leader>ot", ':ObsidianTags<CR>') | ||
490 | vim.keymap.set('n', "<leader>os", ':ObsidianSearch<CR>') | ||
491 | vim.keymap.set('n', "<leader>oq", ':ObsidianQuickSwitch<CR>') | ||
492 | vim.keymap.set('v', "<leader>on", ':ObsidianLinkNew<CR>') | ||
493 | |||
494 | -- [[ Configure Telescope ]] | ||
495 | -- See `:help telescope` and `:help telescope.setup()` | ||
496 | require('telescope').setup { | ||
497 | defaults = { | ||
498 | mappings = { | ||
499 | i = { | ||
500 | ["<c-j>"] = "move_selection_next", | ||
501 | ["<c-k>"] = "move_selection_previous", | ||
502 | ["<C-w>"] = require("telescope.actions.layout").toggle_preview, | ||
503 | }, | ||
504 | }, | ||
505 | layout_config = { | ||
506 | vertical = { height = 0.8 }, | ||
507 | -- other layout configuration here | ||
508 | preview_cutoff = 0, | ||
509 | }, | ||
510 | }, | ||
511 | pickers = { | ||
512 | buffers = { | ||
513 | show_all_buffers = true, | ||
514 | sort_lastused = true, | ||
515 | theme = "dropdown", | ||
516 | previewer = false, | ||
517 | mappings = { | ||
518 | i = { | ||
519 | ["<c-d>"] = "delete_buffer", | ||
520 | }, | ||
521 | n = { | ||
522 | ["<c-d>"] = "delete_buffer", | ||
523 | } | ||
524 | } | ||
525 | } | ||
526 | }, | ||
527 | extensions = { | ||
528 | aerial = { | ||
529 | -- Display symbols as <root>.<parent>.<symbol> | ||
530 | show_nesting = { | ||
531 | ["_"] = false, -- This key will be the default | ||
532 | json = true, -- You can set the option for specific filetypes | ||
533 | yaml = true, | ||
534 | }, | ||
535 | }, | ||
536 | }, | ||
537 | } | ||
538 | |||
539 | -- Enable telescope fzf native, if installed | ||
540 | pcall(require('telescope').load_extension, 'fzf') | ||
541 | |||
542 | -- See `:help telescope.builtin` | ||
543 | vim.keymap.set('n', '<leader>f', require('telescope.builtin').oldfiles, { desc = '[f] Find recently opened files' }) | ||
544 | vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = '[b] Find existing buffers' }) | ||
545 | vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) | ||
546 | vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) | ||
547 | vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) | ||
548 | vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) | ||
549 | vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) | ||
550 | vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) | ||
551 | vim.keymap.set('n', '<leader>sk', require('telescope.builtin').keymaps, { desc = '[S]earch [K]eymaps' }) | ||
552 | vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) | ||
553 | vim.keymap.set('n', '<leader>/', function() | ||
554 | -- You can pass additional configuration to telescope to change theme, layout, etc. | ||
555 | require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { | ||
556 | --winblend = 10, | ||
557 | previewer = false, | ||
558 | }) | ||
559 | end, { desc = '[/] Fuzzily search in current buffer' }) | ||
560 | vim.keymap.set('n', '<leader>sn', function() | ||
561 | require('telescope.builtin').find_files { cwd = vim.fn.stdpath 'config' } | ||
562 | end, { desc = '[S]earch [N]eovim files' }) | ||
563 | |||
564 | -- [[ Configure Treesitter ]] | ||
565 | -- See `:help nvim-treesitter` | ||
566 | require('nvim-treesitter.configs').setup { | ||
567 | -- Add languages to be installed here that you want installed for treesitter | ||
568 | ensure_installed = { 'bash', 'c', 'html', 'css', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, | ||
569 | |||
570 | -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) | ||
571 | auto_install = false, | ||
572 | |||
573 | -- highlight = { enable = true }, | ||
574 | incremental_selection = { | ||
575 | enable = true, | ||
576 | keymaps = { | ||
577 | init_selection = '<c-space>', | ||
578 | node_incremental = '<c-space>', | ||
579 | scope_incremental = '<c-s>', | ||
580 | node_decremental = '<M-space>', | ||
581 | }, | ||
582 | }, | ||
583 | textobjects = { | ||
584 | select = { | ||
585 | enable = true, | ||
586 | lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim | ||
587 | keymaps = { | ||
588 | -- You can use the capture groups defined in textobjects.scm | ||
589 | ['aa'] = '@parameter.outer', | ||
590 | ['ia'] = '@parameter.inner', | ||
591 | ['if'] = '@function.inner', | ||
592 | ['af'] = '@function.outer', | ||
593 | ['ac'] = '@class.outer', | ||
594 | ['ic'] = '@class.inner', | ||
595 | }, | ||
596 | }, | ||
597 | move = { | ||
598 | enable = true, | ||
599 | set_jumps = true, -- whether to set jumps in the jumplist | ||
600 | goto_next_start = { | ||
601 | [']m'] = '@function.outer', | ||
602 | [']]'] = '@class.outer', | ||
603 | }, | ||
604 | goto_next_end = { | ||
605 | [']M'] = '@function.outer', | ||
606 | [']['] = '@class.outer', | ||
607 | }, | ||
608 | goto_previous_start = { | ||
609 | ['[m'] = '@function.outer', | ||
610 | ['[['] = '@class.outer', | ||
611 | }, | ||
612 | goto_previous_end = { | ||
613 | ['[M'] = '@function.outer', | ||
614 | ['[]'] = '@class.outer', | ||
615 | }, | ||
616 | }, | ||
617 | swap = { | ||
618 | enable = true, | ||
619 | swap_next = { | ||
620 | ['<leader>a'] = '@parameter.inner', | ||
621 | }, | ||
622 | swap_previous = { | ||
623 | ['<leader>A'] = '@parameter.inner', | ||
624 | }, | ||
625 | }, | ||
626 | }, | ||
627 | } | ||
628 | |||
629 | -- Diagnostic keymaps | ||
630 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) | ||
631 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) | ||
632 | vim.keymap.set('n', '<leader>E', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) | ||
633 | vim.keymap.set('n', '<leader>Q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) | ||
634 | |||
635 | -- [[ Configure Aerial ]] | ||
636 | require("aerial").setup({ | ||
637 | -- optionally use on_attach to set keymaps when aerial has attached to a buffer | ||
638 | on_attach = function(bufnr) | ||
639 | -- Jump forwards/backwards with '{' and '}' | ||
640 | vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr }) | ||
641 | vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr }) | ||
642 | end, | ||
643 | }) | ||
644 | vim.keymap.set("n", "<leader><leader>a", "<cmd>Telescope aerial<CR>") | ||
645 | vim.keymap.set("n", "<leader><leader>A", "<cmd>AerialToggle!left<CR>") | ||
646 | |||
647 | -- [[ Configure LSP ]] | ||
648 | -- This function gets run when an LSP connects to a particular buffer. | ||
649 | local on_attach = function(_, bufnr) | ||
650 | -- NOTE: Remember that lua is a real programming language, and as such it is possible | ||
651 | -- to define small helper and utility functions so you don't have to repeat yourself | ||
652 | -- many times. | ||
653 | -- | ||
654 | -- In this case, we create a function that lets us more easily define mappings specific | ||
655 | -- for LSP related items. It sets the mode, buffer and description for us each time. | ||
656 | local nmap = function(keys, func, desc) | ||
657 | if desc then | ||
658 | desc = 'LSP: ' .. desc | ||
659 | end | ||
660 | |||
661 | vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) | ||
662 | end | ||
663 | |||
664 | nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') | ||
665 | nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') | ||
666 | |||
667 | nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') | ||
668 | nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') | ||
669 | nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') | ||
670 | nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') | ||
671 | nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') | ||
672 | nmap('<leader><leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') | ||
673 | |||
674 | -- See `:help K` for why this keymap | ||
675 | nmap('K', vim.lsp.buf.hover, 'Hover Documentation') | ||
676 | -- nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') | ||
677 | |||
678 | -- Lesser used LSP functionality | ||
679 | nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') | ||
680 | nmap('<leader><leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') | ||
681 | nmap('<leader><leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') | ||
682 | nmap('<leader><leader>wl', function() | ||
683 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) | ||
684 | end, '[W]orkspace [L]ist Folders') | ||
685 | |||
686 | -- Create a command `:Format` local to the LSP buffer | ||
687 | vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) | ||
688 | vim.lsp.buf.format() | ||
689 | end, { desc = 'Format current buffer with LSP' }) | ||
690 | nmap('<leader>F', ':Format<CR>', 'Format code') | ||
691 | end | ||
692 | |||
693 | -- Enable the following language servers | ||
694 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. | ||
695 | -- | ||
696 | -- Add any additional override configuration in the following tables. They will be passed to | ||
697 | -- the `settings` field of the server config. You must look up that documentation yourself. | ||
698 | -- | ||
699 | -- If you want to override the default filetypes that your language server will attach to you can | ||
700 | -- define the property 'filetypes' to the map in question. | ||
701 | local servers = { | ||
702 | -- clangd = {}, | ||
703 | -- gopls = {}, | ||
704 | -- pyright = {}, | ||
705 | -- rust_analyzer = {}, | ||
706 | -- tsserver = {}, | ||
707 | -- html = { filetypes = { 'html', 'twig', 'hbs'} }, | ||
708 | tsserver = {}, | ||
709 | beancount = { | ||
710 | filetypes = { "beancount", "bean" }, | ||
711 | }, | ||
712 | |||
713 | lua_ls = { | ||
714 | Lua = { | ||
715 | workspace = { checkThirdParty = false }, | ||
716 | telemetry = { enable = false }, | ||
717 | diagnostics = { | ||
718 | -- Get the language server to recognize the `vim` global | ||
719 | globals = { 'vim' }, | ||
720 | }, | ||
721 | }, | ||
722 | }, | ||
723 | } | ||
724 | |||
725 | -- Setup neovim lua configuration | ||
726 | require('neodev').setup() | ||
727 | |||
728 | -- nvim-cmp supports additional completion capabilities, so broadcast that to servers | ||
729 | local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
730 | capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) | ||
731 | |||
732 | -- Ensure the servers above are installed | ||
733 | local mason_lspconfig = require 'mason-lspconfig' | ||
734 | |||
735 | mason_lspconfig.setup { | ||
736 | ensure_installed = vim.tbl_keys(servers), | ||
737 | } | ||
738 | |||
739 | mason_lspconfig.setup_handlers { | ||
740 | function(server_name) | ||
741 | require('lspconfig')[server_name].setup { | ||
742 | capabilities = capabilities, | ||
743 | on_attach = on_attach, | ||
744 | settings = servers[server_name], | ||
745 | filetypes = (servers[server_name] or {}).filetypes, | ||
746 | } | ||
747 | end | ||
748 | } | ||
749 | |||
750 | -- [[ Configure nvim-cmp ]] | ||
751 | -- See `:help cmp` | ||
752 | local cmp = require 'cmp' | ||
753 | local luasnip = require 'luasnip' | ||
754 | require('luasnip.loaders.from_vscode').lazy_load() | ||
755 | luasnip.config.setup {} | ||
756 | |||
757 | cmp.setup { | ||
758 | snippet = { | ||
759 | expand = function(args) | ||
760 | luasnip.lsp_expand(args.body) | ||
761 | end, | ||
762 | }, | ||
763 | mapping = cmp.mapping.preset.insert { | ||
764 | ['<C-n>'] = cmp.mapping.select_next_item(), | ||
765 | ['<C-p>'] = cmp.mapping.select_prev_item(), | ||
766 | ['<C-d>'] = cmp.mapping.scroll_docs(-4), | ||
767 | ['<C-u>'] = cmp.mapping.scroll_docs(4), | ||
768 | ['<C-Space>'] = cmp.mapping.complete {}, | ||
769 | ['<CR>'] = cmp.mapping.confirm { | ||
770 | behavior = cmp.ConfirmBehavior.Replace, | ||
771 | select = false, | ||
772 | }, | ||
773 | ['<Tab>'] = cmp.mapping(function(fallback) | ||
774 | if cmp.visible() then | ||
775 | cmp.select_next_item() | ||
776 | elseif luasnip.expand_or_locally_jumpable() then | ||
777 | luasnip.expand_or_jump() | ||
778 | else | ||
779 | fallback() | ||
780 | end | ||
781 | end, { 'i', 's' }), | ||
782 | ['<S-Tab>'] = cmp.mapping(function(fallback) | ||
783 | if cmp.visible() then | ||
784 | cmp.select_prev_item() | ||
785 | elseif luasnip.locally_jumpable(-1) then | ||
786 | luasnip.jump(-1) | ||
787 | else | ||
788 | fallback() | ||
789 | end | ||
790 | end, { 'i', 's' }), | ||
791 | }, | ||
792 | sources = { | ||
793 | { name = 'nvim_lsp' }, | ||
794 | { name = 'luasnip' }, | ||
795 | }, | ||
796 | } | ||
797 | |||
798 | -- The line beneath this is called `modeline`. See `:help modeline` | ||
799 | -- vim: ts=2 sts=2 sw=2 et | ||