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