this repo has no description
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
23What 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
44Kickstart 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 how 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 sure exactly 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 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 nvim config.
78
79If you experience any errors while trying to install kickstart, run `:checkhealth` for more info
80
81I hope you enjoy your Neovim journey,
82- TJ
83
84P.S. You can delete this when you're done too. It's your config now! :)
85--]]
86
87-- Set <space> as the leader key
88-- See `:help mapleader`
89-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
90vim.g.mapleader = ' '
91vim.g.maplocalleader = ' '
92
93-- Set to true if you have a Nerd Font installed
94vim.g.have_nerd_font = true
95
96-- [[ Setting options ]]
97-- See `:help vim.opt`
98-- NOTE: You can change these options as you wish!
99-- For more options, you can see `:help option-list`
100
101-- Make line numbers default
102vim.opt.number = true
103-- You can also add relative line numbers, for help with jumping.
104-- Experiment for yourself to see if you like it!
105-- vim.opt.relativenumber = true
106
107-- Enable mouse mode, can be useful for resizing splits for example!
108vim.opt.mouse = 'a'
109
110-- Don't show the mode, since it's already in status line
111vim.opt.showmode = false
112
113-- Sync clipboard between OS and Neovim.
114-- Remove this option if you want your OS clipboard to remain independent.
115-- See `:help 'clipboard'`
116vim.opt.clipboard = 'unnamedplus'
117
118-- Enable break indent
119vim.opt.breakindent = true
120
121-- Save undo history
122vim.opt.undofile = true
123
124-- Case-insensitive searching UNLESS \C or capital in search
125vim.opt.ignorecase = true
126vim.opt.smartcase = true
127
128-- Keep signcolumn on by default
129vim.opt.signcolumn = 'yes'
130
131-- Decrease update time
132vim.opt.updatetime = 250
133vim.opt.timeoutlen = 300
134
135-- Configure how new splits should be opened
136vim.opt.splitright = true
137vim.opt.splitbelow = true
138
139-- Sets how neovim will display certain whitespace in the editor.
140-- See `:help 'list'`
141-- and `:help 'listchars'`
142vim.opt.list = true
143vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
144
145-- Preview substitutions live, as you type!
146vim.opt.inccommand = 'split'
147
148-- Show which line your cursor is on
149vim.opt.cursorline = true
150
151-- Minimal number of screen lines to keep above and below the cursor.
152vim.opt.scrolloff = 10
153
154-- [[ Basic Keymaps ]]
155-- See `:help vim.keymap.set()`
156
157-- Set highlight on search, but clear on pressing <Esc> in normal mode
158vim.opt.hlsearch = true
159vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
160
161-- Diagnostic keymaps
162vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
163vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
164vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
165vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
166
167-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
168-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
169-- is not what someone will guess without a bit more experience.
170--
171-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
172-- or just use <C-\><C-n> to exit terminal mode
173vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
174
175-- TIP: Disable arrow keys in normal mode
176-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
177-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
178-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
179-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
180
181-- Keybinds to make split navigation easier.
182-- Use CTRL+<hjkl> to switch between windows
183--
184-- See `:help wincmd` for a list of all window commands
185vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
186vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
187vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
188vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
189
190-- [[ Basic Autocommands ]]
191-- See `:help lua-guide-autocommands`
192
193-- Highlight when yanking (copying) text
194-- Try it with `yap` in normal mode
195-- See `:help vim.highlight.on_yank()`
196vim.api.nvim_create_autocmd('TextYankPost', {
197 desc = 'Highlight when yanking (copying) text',
198 group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
199 callback = function()
200 vim.highlight.on_yank()
201 end,
202})
203
204-- [[ Install `lazy.nvim` plugin manager ]]
205-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
206local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
207if not vim.loop.fs_stat(lazypath) then
208 local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
209 vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
210end ---@diagnostic disable-next-line: undefined-field
211vim.opt.rtp:prepend(lazypath)
212
213-- [[ Configure and install plugins ]]
214--
215-- To check the current status of your plugins, run
216-- :Lazy
217--
218-- You can press `?` in this menu for help. Use `:q` to close the window
219--
220-- To update plugins, you can run
221-- :Lazy update
222--
223-- NOTE: Here is where you install your plugins.
224
225require('lazy').setup({
226 -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
227 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
228
229 {
230 'supermaven-inc/supermaven-nvim',
231 config = function()
232 require('supermaven-nvim').setup {}
233 end,
234 },
235
236 -- NOTE: Plugins can also be added by using a table,
237 -- with the first argument being the link and the following
238 -- keys can be used to configure plugin behavior/loading/etc.
239 --
240 -- Use `opts = {}` to force a plugin to be loaded.
241 --
242 -- This is equivalent to:
243 -- require('Comment').setup({})
244
245 -- "gc" to comment visual regions/lines
246 { 'numToStr/Comment.nvim', opts = {} },
247
248 -- Here is a more advanced example where we pass configuration
249 -- options to `gitsigns.nvim`. This is equivalent to the following lua:
250 -- require('gitsigns').setup({ ... })
251 --
252 -- See `:help gitsigns` to understand what the configuration keys do
253 { -- Adds git related signs to the gutter, as well as utilities for managing changes
254 'lewis6991/gitsigns.nvim',
255 opts = {
256 signs = {
257 add = { text = '+' },
258 change = { text = '~' },
259 delete = { text = '_' },
260 topdelete = { text = '‾' },
261 changedelete = { text = '~' },
262 },
263 },
264 },
265
266 -- NOTE: Plugins can also be configured to run lua code when they are loaded.
267 --
268 -- This is often very useful to both group configuration, as well as handle
269 -- lazy loading plugins that don't need to be loaded immediately at startup.
270 --
271 -- For example, in the following configuration, we use:
272 -- event = 'VimEnter'
273 --
274 -- which loads which-key before all the UI elements are loaded. Events can be
275 -- normal autocommands events (`:help autocmd-events`).
276 --
277 -- Then, because we use the `config` key, the configuration only runs
278 -- after the plugin has been loaded:
279 -- config = function() ... end
280
281 -- { -- Useful plugin to show you pending keybinds.
282 -- 'folke/which-key.nvim',
283 -- event = 'VimEnter', -- Sets the loading event to 'VimEnter'
284 -- config = function() -- This is the function that runs, AFTER loading
285 -- require('which-key').setup()
286 -- require('which-key').register {
287 -- ['<leader>'] = {
288 -- c = { name = '[C]ode' },
289 -- d = { name = '[D]ocument' },
290 -- r = { name = '[R]ename' },
291 -- s = { name = '[S]earch' },
292 -- w = { name = '[W]orkspace' },
293 -- }
294 -- }
295 -- end,
296 -- },
297
298 -- NOTE: Plugins can specify dependencies.
299 --
300 -- The dependencies are proper plugin specifications as well - anything
301 -- you do for a plugin at the top level, you can do for a dependency.
302 --
303 -- Use the `dependencies` key to specify the dependencies of a particular plugin
304 -- Use the `dependencies` key to specify the dependencies of a particular plugin
305
306 { -- Fuzzy Finder (files, lsp, etc)
307 'nvim-telescope/telescope.nvim',
308 event = 'VimEnter',
309 branch = '0.1.x',
310 dependencies = {
311 'nvim-lua/plenary.nvim',
312 { -- If encountering errors, see telescope-fzf-native README for install instructions
313 'nvim-telescope/telescope-fzf-native.nvim',
314
315 -- `build` is used to run some command when the plugin is installed/updated.
316 -- This is only run then, not every time Neovim starts up.
317 build = 'make',
318
319 -- `cond` is a condition used to determine whether this plugin should be
320 -- installed and loaded.
321 cond = function()
322 return vim.fn.executable 'make' == 1
323 end,
324 },
325 { 'nvim-telescope/telescope-ui-select.nvim' },
326
327 -- Useful for getting pretty icons, but requires a Nerd Font.
328 { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
329 },
330 config = function()
331 -- Telescope is a fuzzy finder that comes with a lot of different things that
332 -- it can fuzzy find! It's more than just a "file finder", it can search
333 -- many different aspects of Neovim, your workspace, LSP, and more!
334 --
335 -- The easiest way to use telescope, is to start by doing something like:
336 -- :Telescope help_tags
337 --
338 -- After running this command, a window will open up and you're able to
339 -- type in the prompt window. You'll see a list of help_tags options and
340 -- a corresponding preview of the help.
341 --
342 -- Two important keymaps to use while in telescope are:
343 -- - Insert mode: <c-/>
344 -- - Normal mode: ?
345 --
346 -- This opens a window that shows you all of the keymaps for the current
347 -- telescope picker. This is really useful to discover what Telescope can
348 -- do as well as how to actually do it!
349
350 -- [[ Configure Telescope ]]
351 -- See `:help telescope` and `:help telescope.setup()`
352 require('telescope').setup {
353 -- You can put your default mappings / updates / etc. in here
354 -- All the info you're looking for is in `:help telescope.setup()`
355 --
356 -- defaults = {
357 -- mappings = {
358 -- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
359 -- },
360 -- },
361 -- pickers = {}
362 extensions = {
363 ['ui-select'] = {
364 require('telescope.themes').get_dropdown(),
365 },
366 },
367 }
368
369 -- Enable telescope extensions, if they are installed
370 pcall(require('telescope').load_extension, 'fzf')
371 pcall(require('telescope').load_extension, 'ui-select')
372
373 -- See `:help telescope.builtin`
374 local builtin = require 'telescope.builtin'
375 vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
376 vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
377 vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
378 vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
379 vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
380 vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
381 vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
382 vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
383 vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
384 vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
385
386 -- Slightly advanced example of overriding default behavior and theme
387 vim.keymap.set('n', '<leader>/', function()
388 -- You can pass additional configuration to telescope to change theme, layout, etc.
389 builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
390 winblend = 10,
391 previewer = false,
392 })
393 end, { desc = '[/] Fuzzily search in current buffer' })
394
395 -- Also possible to pass additional configuration options.
396 -- See `:help telescope.builtin.live_grep()` for information about particular keys
397 vim.keymap.set('n', '<leader>s/', function()
398 builtin.live_grep {
399 grep_open_files = true,
400 prompt_title = 'Live Grep in Open Files',
401 }
402 end, { desc = '[S]earch [/] in Open Files' })
403
404 -- Shortcut for searching your neovim configuration files
405 vim.keymap.set('n', '<leader>sn', function()
406 builtin.find_files { cwd = vim.fn.stdpath 'config' }
407 end, { desc = '[S]earch [N]eovim files' })
408 end,
409 },
410
411 { -- LSP Configuration & Plugins
412 'neovim/nvim-lspconfig',
413 dependencies = {
414 -- Automatically install LSPs and related tools to stdpath for neovim
415 'williamboman/mason.nvim',
416 'williamboman/mason-lspconfig.nvim',
417 'WhoIsSethDaniel/mason-tool-installer.nvim',
418
419 -- Useful status updates for LSP.
420 -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
421 { 'j-hui/fidget.nvim', opts = {} },
422 },
423 config = function()
424 -- Brief Aside: **What is LSP?**
425 --
426 -- LSP is an acronym you've probably heard, but might not understand what it is.
427 --
428 -- LSP stands for Language Server Protocol. It's a protocol that helps editors
429 -- and language tooling communicate in a standardized fashion.
430 --
431 -- In general, you have a "server" which is some tool built to understand a particular
432 -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc). These Language Servers
433 -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
434 -- processes that communicate with some "client" - in this case, Neovim!
435 --
436 -- LSP provides Neovim with features like:
437 -- - Go to definition
438 -- - Find references
439 -- - Autocompletion
440 -- - Symbol Search
441 -- - and more!
442 --
443 -- Thus, Language Servers are external tools that must be installed separately from
444 -- Neovim. This is where `mason` and related plugins come into play.
445 --
446 -- If you're wondering about lsp vs treesitter, you can check out the wonderfully
447 -- and elegantly composed help section, `:help lsp-vs-treesitter`
448
449 -- This function gets run when an LSP attaches to a particular buffer.
450 -- That is to say, every time a new file is opened that is associated with
451 -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
452 -- function will be executed to configure the current buffer
453 vim.api.nvim_create_autocmd('LspAttach', {
454 group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
455 callback = function(event)
456 -- NOTE: Remember that lua is a real programming language, and as such it is possible
457 -- to define small helper and utility functions so you don't have to repeat yourself
458 -- many times.
459 --
460 -- In this case, we create a function that lets us more easily define mappings specific
461 -- for LSP related items. It sets the mode, buffer and description for us each time.
462 local map = function(keys, func, desc)
463 vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
464 end
465
466 -- Jump to the definition of the word under your cursor.
467 -- This is where a variable was first declared, or where a function is defined, etc.
468 -- To jump back, press <C-t>.
469 map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
470
471 -- Find references for the word under your cursor.
472 map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
473
474 -- Jump to the implementation of the word under your cursor.
475 -- Useful when your language has ways of declaring types without an actual implementation.
476 map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
477
478 -- Jump to the type of the word under your cursor.
479 -- Useful when you're not sure what type a variable is and you want to see
480 -- the definition of its *type*, not where it was *defined*.
481 map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
482
483 -- Fuzzy find all the symbols in your current document.
484 -- Symbols are things like variables, functions, types, etc.
485 map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
486
487 -- Fuzzy find all the symbols in your current workspace
488 -- Similar to document symbols, except searches over your whole project.
489 map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
490
491 -- Rename the variable under your cursor
492 -- Most Language Servers support renaming across files, etc.
493 map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
494
495 -- Execute a code action, usually your cursor needs to be on top of an error
496 -- or a suggestion from your LSP for this to activate.
497 map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
498
499 -- Opens a popup that displays documentation about the word under your cursor
500 -- See `:help K` for why this keymap
501 map('K', vim.lsp.buf.hover, 'Hover Documentation')
502
503 -- WARN: This is not Goto Definition, this is Goto Declaration.
504 -- For example, in C this would take you to the header
505 map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
506
507 -- The following two autocommands are used to highlight references of the
508 -- word under your cursor when your cursor rests there for a little while.
509 -- See `:help CursorHold` for information about when this is executed
510 --
511 -- When you move your cursor, the highlights will be cleared (the second autocommand).
512 local client = vim.lsp.get_client_by_id(event.data.client_id)
513 if client and client.server_capabilities.documentHighlightProvider then
514 vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
515 buffer = event.buf,
516 callback = vim.lsp.buf.document_highlight,
517 })
518
519 vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
520 buffer = event.buf,
521 callback = vim.lsp.buf.clear_references,
522 })
523 end
524 end,
525 })
526
527 -- LSP servers and clients are able to communicate to each other what features they support.
528 -- By default, Neovim doesn't support everything that is in the LSP Specification.
529 -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
530 -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
531 local capabilities = vim.lsp.protocol.make_client_capabilities()
532 capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
533
534 -- Enable the following language servers
535 -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
536 --
537 -- Add any additional override configuration in the following tables. Available keys are:
538 -- - cmd (table): Override the default command used to start the server
539 -- - filetypes (table): Override the default list of associated filetypes for the server
540 -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
541 -- - settings (table): Override the default settings passed when initializing the server.
542 -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
543 local servers = {
544 -- clangd = {},
545 -- gopls = {},
546 -- pyright = {},
547 -- rust_analyzer = {},
548 -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
549 --
550 -- Some languages (like typescript) have entire language plugins that can be useful:
551 -- https://github.com/pmizio/typescript-tools.nvim
552 --
553 -- But for many setups, the LSP (`tsserver`) will work just fine
554 -- tsserver = {},
555 --
556
557 lua_ls = {
558 -- cmd = {...},
559 -- filetypes { ...},
560 -- capabilities = {},
561 settings = {
562 Lua = {
563 runtime = { version = 'LuaJIT' },
564 workspace = {
565 checkThirdParty = false,
566 -- Tells lua_ls where to find all the Lua files that you have loaded
567 -- for your neovim configuration.
568 library = {
569 '${3rd}/luv/library',
570 unpack(vim.api.nvim_get_runtime_file('', true)),
571 },
572 -- If lua_ls is really slow on your computer, you can try this instead:
573 -- library = { vim.env.VIMRUNTIME },
574 },
575 completion = {
576 callSnippet = 'Replace',
577 },
578 -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
579 -- diagnostics = { disable = { 'missing-fields' } },
580 },
581 },
582 },
583
584 ruff = {
585 init_options = {
586 settings = {
587 -- Any extra CLI arguments for `ruff` go here.
588 args = {},
589 },
590 },
591 },
592 }
593
594 -- Ensure the servers and tools above are installed
595 -- To check the current status of installed tools and/or manually install
596 -- other tools, you can run
597 -- :Mason
598 --
599 -- You can press `g?` for help in this menu
600 require('mason').setup()
601
602 -- You can add other tools here that you want Mason to install
603 -- for you, so that they are available from within Neovim.
604 local ensure_installed = vim.tbl_keys(servers or {})
605 vim.list_extend(ensure_installed, {
606 'stylua', -- Used to format lua code
607 'ruff', -- Python linter (new integrated server)
608 'pyright', -- Python type checker
609 })
610 require('mason-tool-installer').setup { ensure_installed = ensure_installed }
611
612 require('mason-lspconfig').setup {
613 handlers = {
614 function(server_name)
615 local server = servers[server_name] or {}
616 -- This handles overriding only values explicitly passed
617 -- by the server configuration above. Useful when disabling
618 -- certain features of an LSP (for example, turning off formatting for tsserver)
619 server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
620 require('lspconfig')[server_name].setup(server)
621 end,
622 },
623 }
624 end,
625 },
626
627 { -- Autoformat
628 'stevearc/conform.nvim',
629 opts = {
630 notify_on_error = false,
631 format_on_save = {
632 timeout_ms = 500,
633 lsp_fallback = true,
634 },
635 formatters_by_ft = {
636 lua = { 'stylua' },
637 python = { 'ruff_format' }, -- Use Ruff for Python formatting
638 },
639 },
640 },
641
642 { -- Autocompletion
643 'hrsh7th/nvim-cmp',
644 event = 'InsertEnter',
645 dependencies = {
646 -- Snippet Engine & its associated nvim-cmp source
647 {
648 'L3MON4D3/LuaSnip',
649 build = (function()
650 -- Build Step is needed for regex support in snippets
651 -- This step is not supported in many windows environments
652 -- Remove the below condition to re-enable on windows
653 if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
654 return
655 end
656 return 'make install_jsregexp'
657 end)(),
658 },
659 'saadparwaiz1/cmp_luasnip',
660
661 -- Adds other completion capabilities.
662 -- nvim-cmp does not ship with all sources by default. They are split
663 -- into multiple repos for maintenance purposes.
664 'hrsh7th/cmp-nvim-lsp',
665 'hrsh7th/cmp-path',
666
667 -- If you want to add a bunch of pre-configured snippets,
668 -- you can use this plugin to help you. It even has snippets
669 -- for various frameworks/libraries/etc. but you will have to
670 -- set up the ones that are useful for you.
671 -- 'rafamadriz/friendly-snippets',
672 },
673 config = function()
674 -- See `:help cmp`
675 local cmp = require 'cmp'
676 local luasnip = require 'luasnip'
677 luasnip.config.setup {}
678
679 cmp.setup {
680 snippet = {
681 expand = function(args)
682 luasnip.lsp_expand(args.body)
683 end,
684 },
685 completion = { completeopt = 'menu,menuone,noinsert' },
686
687 -- For an understanding of why these mappings were
688 -- chosen, you will need to read `:help ins-completion`
689 --
690 -- No, but seriously. Please read `:help ins-completion`, it is really good!
691 mapping = cmp.mapping.preset.insert {
692 -- Select the [n]ext item
693 ['<C-n>'] = cmp.mapping.select_next_item(),
694 -- Select the [p]revious item
695 ['<C-p>'] = cmp.mapping.select_prev_item(),
696
697 -- Accept ([y]es) the completion.
698 -- This will auto-import if your LSP supports it.
699 -- This will expand snippets if the LSP sent a snippet.
700 ['<C-y>'] = cmp.mapping.confirm { select = true },
701
702 -- Manually trigger a completion from nvim-cmp.
703 -- Generally you don't need this, because nvim-cmp will display
704 -- completions whenever it has completion options available.
705 ['<C-Space>'] = cmp.mapping.complete {},
706
707 -- Think of <c-l> as moving to the right of your snippet expansion.
708 -- So if you have a snippet that's like:
709 -- function $name($args)
710 -- $body
711 -- end
712 --
713 -- <c-l> will move you to the right of each of the expansion locations.
714 -- <c-h> is similar, except moving you backwards.
715 ['<C-l>'] = cmp.mapping(function()
716 if luasnip.expand_or_locally_jumpable() then
717 luasnip.expand_or_jump()
718 end
719 end, { 'i', 's' }),
720 ['<C-h>'] = cmp.mapping(function()
721 if luasnip.locally_jumpable(-1) then
722 luasnip.jump(-1)
723 end
724 end, { 'i', 's' }),
725 },
726 sources = {
727 { name = 'nvim_lsp' },
728 { name = 'luasnip' },
729 { name = 'path' },
730 },
731 }
732 end,
733 },
734
735 { -- You can easily change to a different colorscheme.
736 -- Change the name of the colorscheme plugin below, and then
737 -- change the command in the config to whatever the name of that colorscheme is
738 --
739 -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`
740 'folke/tokyonight.nvim',
741 priority = 1000, -- make sure to load this before all the other start plugins
742 init = function()
743 -- Load the colorscheme here.
744 -- Like many other themes, this one has different styles, and you could load
745 -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
746 vim.cmd.colorscheme 'tokyonight-night'
747
748 -- You can configure highlights by doing something like
749 vim.cmd.hi 'Comment gui=none'
750 end,
751 },
752
753 -- Highlight todo, notes, etc in comments
754 { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
755
756 { -- Collection of various small independent plugins/modules
757 'echasnovski/mini.nvim',
758 config = function()
759 -- Better Around/Inside textobjects
760 --
761 -- Examples:
762 -- - va) - [V]isually select [A]round [)]paren
763 -- - yinq - [Y]ank [I]nside [N]ext [']quote
764 -- - ci' - [C]hange [I]nside [']quote
765 require('mini.ai').setup { n_lines = 500 }
766
767 -- Add/delete/replace surroundings (brackets, quotes, etc.)
768 --
769 -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
770 -- - sd' - [S]urround [D]elete [']quotes
771 -- - sr)' - [S]urround [R]eplace [)] [']
772 require('mini.surround').setup()
773
774 -- Simple and easy statusline.
775 -- You could remove this setup call if you don't like it,
776 -- and try some other statusline plugin
777 local statusline = require 'mini.statusline'
778 -- set use_icons to true if you have a Nerd Font
779 statusline.setup { use_icons = vim.g.have_nerd_font }
780
781 -- You can configure sections in the statusline by overriding their
782 -- default behavior. For example, here we set the section for
783 -- cursor location to LINE:COLUMN
784 ---@diagnostic disable-next-line: duplicate-set-field
785 statusline.section_location = function()
786 return '%2l:%-2v'
787 end
788
789 -- ... and there is more!
790 -- Check out: https://github.com/echasnovski/mini.nvim
791 end,
792 },
793
794 { -- Highlight, edit, and navigate code
795 'nvim-treesitter/nvim-treesitter',
796 build = ':TSUpdate',
797 opts = {
798 ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' },
799 -- Autoinstall languages that are not installed
800 auto_install = true,
801 highlight = { enable = true },
802 indent = { enable = true },
803 },
804 config = function(_, opts)
805 -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
806
807 ---@diagnostic disable-next-line: missing-fields
808 require('nvim-treesitter.configs').setup(opts)
809
810 -- There are additional nvim-treesitter modules that you can use to interact
811 -- with nvim-treesitter. You should go explore a few and see what interests you:
812 --
813 -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
814 -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
815 -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
816 end,
817 },
818
819 {
820 'iamcco/markdown-preview.nvim',
821 cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
822 ft = { 'markdown' },
823 build = function()
824 vim.fn['mkdp#util#install']()
825 end,
826 },
827
828 -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
829 -- init.lua. If you want these files, they are in the repository, so you can just download them and
830 -- put them in the right spots if you want.
831
832 -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart
833 --
834 -- Here are some example plugins that I've included in the kickstart repository.
835 -- Uncomment any of the lines below to enable them (you will need to restart nvim).
836 --
837 -- require 'kickstart.plugins.debug',
838 -- require 'kickstart.plugins.indent_line',
839
840 -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
841 -- This is the easiest way to modularize your config.
842 --
843 -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
844 -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
845 -- { import = 'custom.plugins' },
846}, {
847 ui = {
848 -- If you have a Nerd Font, set icons to an empty table which will use the
849 -- default lazy.nvim defined Nerd Font icons otherwise define a unicode icons table
850 icons = vim.g.have_nerd_font and {} or {
851 cmd = '⌘',
852 config = '🛠',
853 event = '📅',
854 ft = '📂',
855 init = '⚙',
856 keys = '🗝',
857 plugin = '🔌',
858 runtime = '💻',
859 require = '🌙',
860 source = '📄',
861 start = '🚀',
862 task = '📌',
863 lazy = '💤 ',
864 },
865 },
866})
867
868-- The line beneath this is called `modeline`. See `:help modeline`
869-- vim: ts=2 sts=2 sw=2 et