@ -127,7 +127,6 @@ vim.opt.signcolumn = 'yes'
vim.opt . updatetime = 250
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
vim.opt . timeoutlen = 300
-- Configure how new splits should be opened
@ -152,14 +151,11 @@ vim.opt.scrolloff = 10
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- Set highlight on search, but clear o n pressing <Esc> in normal mode
vim.opt . hlsearch = true
-- Clear highlights on search whe n pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap . set ( ' n ' , ' <Esc> ' , ' <cmd>nohlsearch<CR> ' )
-- Diagnostic keymaps
vim.keymap . set ( ' n ' , ' [d ' , vim.diagnostic . goto_prev , { desc = ' Go to previous [D]iagnostic message ' } )
vim.keymap . set ( ' n ' , ' ]d ' , vim.diagnostic . goto_next , { desc = ' Go to next [D]iagnostic message ' } )
vim.keymap . set ( ' n ' , ' <leader>e ' , vim.diagnostic . open_float , { desc = ' Show diagnostic [E]rror messages ' } )
vim.keymap . set ( ' n ' , ' <leader>q ' , vim.diagnostic . setloclist , { desc = ' Open diagnostic [Q]uickfix list ' } )
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@ -202,9 +198,12 @@ vim.api.nvim_create_autocmd('TextYankPost', {
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn . stdpath ' data ' .. ' /lazy/lazy.nvim '
if not vim.loop . fs_stat ( lazypath ) then
if not ( vim.uv or vim.loop ) . fs_stat ( lazypath ) then
local lazyrepo = ' https://github.com/folke/lazy.nvim.git '
vim.fn . system { ' git ' , ' clone ' , ' --filter=blob:none ' , ' --branch=stable ' , lazyrepo , lazypath }
local out = vim.fn . system { ' git ' , ' clone ' , ' --filter=blob:none ' , ' --branch=stable ' , lazyrepo , lazypath }
if vim.v . shell_error ~= 0 then
error ( ' Error cloning lazy.nvim: \n ' .. out )
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt . rtp : prepend ( lazypath )
@ -227,17 +226,22 @@ require('lazy').setup({
-- with the first argument being the link and the following
-- keys can be used to configure plugin behavior/loading/etc.
--
-- Use `opts = {}` to force a plugin to be loaded.
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
--
-- This is equivalent to:
-- require('Comment').setup({})
-- "gc" to comment visual regions/lines
{ ' numToStr/Comment.nvim ' , opts = { } } ,
-- Alternatively, use `config = function() ... end` for full control over the configuration.
-- If you prefer to call `setup` explicitly, use:
-- {
-- 'lewis6991/gitsigns.nvim',
-- config = function()
-- require('gitsigns').setup({
-- -- Your gitsigns configuration here
-- })
-- end,
-- }
--
-- Here is a more advanced example where we pass configuration
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
-- require('gitsigns').setup({ ... })
-- options to `gitsigns.nvim`.
--
-- See `:help gitsigns` to understand what the configuration keys do
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
@ -264,31 +268,64 @@ require('lazy').setup({
-- which loads which-key before all the UI elements are loaded. Events can be
-- normal autocommands events (`:help autocmd-events`).
--
-- Then, because we use the `config` key, the configuration only runs
-- after the plugin has been loaded:
-- config = function() ... end
-- Then, because we use the `opts` key (recommended), the configuration runs
-- after the plugin has been loaded as `require(MODULE).setup(opts)`.
{ -- Useful plugin to show you pending keybinds.
' folke/which-key.nvim ' ,
event = ' VimEnter ' , -- Sets the loading event to 'VimEnter'
config = function ( ) -- This is the function that runs, AFTER loading
require ( ' which-key ' ) . setup ( )
opts = {
-- delay between pressing a key and opening which-key (milliseconds)
-- this setting is independent of vim.opt.timeoutlen
delay = 0 ,
icons = {
-- set icon mappings to true if you have a Nerd Font
mappings = vim.g . have_nerd_font ,
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
keys = vim.g . have_nerd_font and { } or {
Up = ' <Up> ' ,
Down = ' <Down> ' ,
Left = ' <Left> ' ,
Right = ' <Right> ' ,
C = ' <C-…> ' ,
M = ' <M-…> ' ,
D = ' <D-…> ' ,
S = ' <S-…> ' ,
CR = ' <CR> ' ,
Esc = ' <Esc> ' ,
ScrollWheelDown = ' <ScrollWheelDown> ' ,
ScrollWheelUp = ' <ScrollWheelUp> ' ,
NL = ' <NL> ' ,
BS = ' <BS> ' ,
Space = ' <Space> ' ,
Tab = ' <Tab> ' ,
F1 = ' <F1> ' ,
F2 = ' <F2> ' ,
F3 = ' <F3> ' ,
F4 = ' <F4> ' ,
F5 = ' <F5> ' ,
F6 = ' <F6> ' ,
F7 = ' <F7> ' ,
F8 = ' <F8> ' ,
F9 = ' <F9> ' ,
F10 = ' <F10> ' ,
F11 = ' <F11> ' ,
F12 = ' <F12> ' ,
} ,
} ,
-- Document existing key chains
require ( ' which-key ' ) . register {
[ ' <leader>c ' ] = { name = ' [C]ode ' , _ = ' which_key_ignore ' } ,
[ ' <leader>d ' ] = { name = ' [D]ocument ' , _ = ' which_key_ignore ' } ,
[ ' <leader>r ' ] = { name = ' [R]ename ' , _ = ' which_key_ignore ' } ,
[ ' <leader>s ' ] = { name = ' [S]earch ' , _ = ' which_key_ignore ' } ,
[ ' <leader>w ' ] = { name = ' [W]orkspace ' , _ = ' which_key_ignore ' } ,
[ ' <leader>t ' ] = { name = ' [T]oggle ' , _ = ' which_key_ignore ' } ,
[ ' <leader>h ' ] = { name = ' Git [H]unk ' , _ = ' which_key_ignore ' } ,
}
-- visual mode
require ( ' which-key ' ) . register ( {
[ ' <leader>h ' ] = { ' Git [H]unk ' } ,
} , { mode = ' v ' } )
end ,
spec = {
{ ' <leader>c ' , group = ' [C]ode ' , mode = { ' n ' , ' x ' } } ,
{ ' <leader>d ' , group = ' [D]ocument ' } ,
{ ' <leader>r ' , group = ' [R]ename ' } ,
{ ' <leader>s ' , group = ' [S]earch ' } ,
{ ' <leader>w ' , group = ' [W]orkspace ' } ,
{ ' <leader>t ' , group = ' [T]oggle ' } ,
{ ' <leader>h ' , group = ' Git [H]unk ' , mode = { ' n ' , ' v ' } } ,
} ,
} ,
} ,
-- NOTE: Plugins can specify dependencies.
@ -403,21 +440,35 @@ require('lazy').setup({
end ,
} ,
{ -- LSP Configuration & Plugins
-- LSP Plugins
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
' folke/lazydev.nvim ' ,
ft = ' lua ' ,
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = ' ${3rd}/luv/library ' , words = { ' vim%.uv ' } } ,
} ,
} ,
} ,
{
-- Main LSP Configuration
' neovim/nvim-lspconfig ' ,
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
{ ' williamboman/mason.nvim ' , config = true } , -- NOTE: Must be loaded before dependants
-- Mason must be loaded before its dependents so we need to set it up here.
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ ' williamboman/mason.nvim ' , opts = { } } ,
' williamboman/mason-lspconfig.nvim ' ,
' WhoIsSethDaniel/mason-tool-installer.nvim ' ,
-- Useful status updates for LSP.
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ ' j-hui/fidget.nvim ' , opts = { } } ,
-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
{ ' folke/neodev.nvim ' , opts = { } } ,
-- Allows extra capabilities provided by nvim-cmp
' hrsh7th/cmp-nvim-lsp ' ,
} ,
config = function ( )
-- Brief aside: **What is LSP?**
@ -457,8 +508,9 @@ require('lazy').setup({
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function ( keys , func , desc )
vim.keymap . set ( ' n ' , keys , func , { buffer = event.buf , desc = ' LSP: ' .. desc } )
local map = function ( keys , func , desc , mode )
mode = mode or ' n '
vim.keymap . set ( mode , keys , func , { buffer = event.buf , desc = ' LSP: ' .. desc } )
end
-- Jump to the definition of the word under your cursor.
@ -492,23 +544,32 @@ require('lazy').setup({
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
map ( ' <leader>ca ' , vim.lsp . buf.code_action , ' [C]ode [A]ction ' )
-- Opens a popup that displays documentation about the word under your cursor
-- See `:help K` for why this keymap.
map ( ' K ' , vim.lsp . buf.hover , ' Hover Documentation ' )
map ( ' <leader>ca ' , vim.lsp . buf.code_action , ' [C]ode [A]ction ' , { ' n ' , ' x ' } )
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map ( ' gD ' , vim.lsp . buf.declaration , ' [G]oto [D]eclaration ' )
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client
---@param method vim.lsp.protocol.Method
---@param bufnr? integer some lsp support methods only in specific files
---@return boolean
local function client_supports_method ( client , method , bufnr )
if vim.fn . has ' nvim-0.11 ' == 1 then
return client : supports_method ( method , bufnr )
else
return client.supports_method ( method , { bufnr = bufnr } )
end
end
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp . get_client_by_id ( event.data . client_id )
if client and client.server_capabilities . documentHighlightProvider then
if client and client _supports_method( client , vim.lsp . protocol.Methods . textDocument_documentHighlight , event.buf ) then
local highlight_augroup = vim.api . nvim_create_augroup ( ' kickstart-lsp-highlight ' , { clear = false } )
vim.api . nvim_create_autocmd ( { ' CursorHold ' , ' CursorHoldI ' } , {
buffer = event.buf ,
@ -531,18 +592,47 @@ require('lazy').setup({
} )
end
-- The following autocommand is used to enab le inlay hints in your
-- The following code creates a keymap to togg le inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client .server_capabilities. inlayHintProvider and vim.lsp . inlay_hint then
if client and client _supports_method( client , vim.lsp . protocol.Methods . textDocument_inlayHint , event.buf ) then
map ( ' <leader>th ' , function ( )
vim.lsp . inlay_hint.enable ( not vim.lsp . inlay_hint.is_enabled ( ) )
vim.lsp . inlay_hint.enable ( not vim.lsp . inlay_hint.is_enabled { bufnr = event.buf } )
end , ' [T]oggle Inlay [H]ints ' )
end
end ,
} )
-- Diagnostic Config
-- See :help vim.diagnostic.Opts
vim.diagnostic . config {
severity_sort = true ,
float = { border = ' rounded ' , source = ' if_many ' } ,
underline = { severity = vim.diagnostic . severity.ERROR } ,
signs = vim.g . have_nerd_font and {
text = {
[ vim.diagnostic . severity.ERROR ] = ' ' ,
[ vim.diagnostic . severity.WARN ] = ' ' ,
[ vim.diagnostic . severity.INFO ] = ' ' ,
[ vim.diagnostic . severity.HINT ] = ' ' ,
} ,
} or { } ,
virtual_text = {
source = ' if_many ' ,
spacing = 2 ,
format = function ( diagnostic )
local diagnostic_message = {
[ vim.diagnostic . severity.ERROR ] = diagnostic.message ,
[ vim.diagnostic . severity.WARN ] = diagnostic.message ,
[ vim.diagnostic . severity.INFO ] = diagnostic.message ,
[ vim.diagnostic . severity.HINT ] = diagnostic.message ,
}
return diagnostic_message [ diagnostic.severity ]
end ,
} ,
}
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
@ -569,13 +659,13 @@ require('lazy').setup({
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts server `) will work just fine
-- ts server = {},
-- But for many setups, the LSP (`ts _l s`) will work just fine
-- ts _l s = {},
--
lua_ls = {
-- cmd = { ...},
-- filetypes = { ... },
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = {
Lua = {
@ -590,13 +680,16 @@ require('lazy').setup({
}
-- Ensure the servers and tools above are installed
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
--
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- :Mason
--
-- You can press `g?` for help in this menu.
require ( ' mason ' ) . setup ( )
-- You can press `g?` for help in this menu.
--
-- `mason` had to be setup earlier: to configure its options see the
-- `dependencies` table for `nvim-lspconfig` above.
--
-- You can add other tools here that you want Mason to install
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys ( servers or { } )
@ -606,12 +699,14 @@ require('lazy').setup({
require ( ' mason-tool-installer ' ) . setup { ensure_installed = ensure_installed }
require ( ' mason-lspconfig ' ) . setup {
ensure_installed = { } , -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
automatic_installation = false ,
handlers = {
function ( server_name )
local server = servers [ server_name ] or { }
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts server )
-- certain features of an LSP (for example, turning off formatting for ts _l s)
server.capabilities = vim.tbl_deep_extend ( ' force ' , { } , capabilities , server.capabilities or { } )
require ( ' lspconfig ' ) [ server_name ] . setup ( server )
end ,
@ -622,12 +717,13 @@ require('lazy').setup({
{ -- Autoformat
' stevearc/conform.nvim ' ,
lazy = false ,
event = { ' BufWritePre ' } ,
cmd = { ' ConformInfo ' } ,
keys = {
{
' <leader>f ' ,
function ( )
require ( ' conform ' ) . format { async = true , lsp_f allback = true }
require ( ' conform ' ) . format { async = true , lsp_f ormat = ' fallback ' }
end ,
mode = ' ' ,
desc = ' [F]ormat buffer ' ,
@ -640,9 +736,15 @@ require('lazy').setup({
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true , cpp = true }
local lsp_format_opt
if disable_filetypes [ vim.bo [ bufnr ] . filetype ] then
lsp_format_opt = ' never '
else
lsp_format_opt = ' fallback '
end
return {
timeout_ms = 500 ,
lsp_fallback = not disable_filetypes [ vim.bo [ bufnr ] . filetype ] ,
lsp_f ormat = lsp_format_opt ,
}
end ,
formatters_by_ft = {
@ -650,9 +752,8 @@ require('lazy').setup({
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use a sub-list to tell conform to run *until* a formatter
-- is found.
-- javascript = { { "prettierd", "prettier" } },
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
} ,
} ,
} ,
@ -692,6 +793,7 @@ require('lazy').setup({
-- into multiple repos for maintenance purposes.
' hrsh7th/cmp-nvim-lsp ' ,
' hrsh7th/cmp-path ' ,
' hrsh7th/cmp-nvim-lsp-signature-help ' ,
} ,
config = function ( )
-- See `:help cmp`
@ -760,9 +862,15 @@ require('lazy').setup({
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
} ,
sources = {
{
name = ' lazydev ' ,
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0 ,
} ,
{ name = ' nvim_lsp ' } ,
{ name = ' luasnip ' } ,
{ name = ' path ' } ,
{ name = ' nvim_lsp_signature_help ' } ,
} ,
}
end ,
@ -775,14 +883,18 @@ require('lazy').setup({
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
' folke/tokyonight.nvim ' ,
priority = 1000 , -- Make sure to load this before all the other start plugins.
init = function ( )
config = function ( )
---@diagnostic disable-next-line: missing-fields
require ( ' tokyonight ' ) . setup {
styles = {
comments = { italic = false } , -- Disable italics in comments
} ,
}
-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd . colorscheme ' tokyonight-night '
-- You can configure highlights by doing something like:
vim.cmd . hi ' Comment gui=none '
end ,
} ,
@ -796,7 +908,7 @@ require('lazy').setup({
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [ ']q uote
-- - yinq - [Y]ank [I]nside [N]ext [ Q] uote
-- - ci' - [C]hange [I]nside [']quote
require ( ' mini.ai ' ) . setup { n_lines = 500 }
@ -829,8 +941,10 @@ require('lazy').setup({
{ -- Highlight, edit, and navigate code
' nvim-treesitter/nvim-treesitter ' ,
build = ' :TSUpdate ' ,
main = ' nvim-treesitter.configs ' , -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = { ' bash ' , ' c ' , ' diff ' , ' html ' , ' lua ' , ' luadoc ' , ' markdown ' , ' vim ' , ' vimdoc ' } ,
ensure_installed = { ' bash ' , ' c ' , ' diff ' , ' html ' , ' lua ' , ' luadoc ' , ' markdown ' , ' markdown_inline' , ' query ' , ' vim' , ' vimdoc ' } ,
-- Autoinstall languages that are not installed
auto_install = true ,
highlight = {
@ -842,24 +956,15 @@ require('lazy').setup({
} ,
indent = { enable = true , disable = { ' ruby ' } } ,
} ,
config = function ( _ , opts )
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
-- Prefer git instead of curl in order to improve connectivity in some environments
require ( ' nvim-treesitter.install ' ) . prefer_git = true
---@diagnostic disable-next-line: missing-fields
require ( ' nvim-treesitter.configs ' ) . setup ( opts )
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
end ,
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
} ,
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
-- init.lua. If you want these files, they are in the repository, so you can just download them and
-- place them in the correct locations.
@ -879,8 +984,12 @@ require('lazy').setup({
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' },
--
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope!
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
-- you can continue same window with `<space>sr` which resumes last telescope search
} , {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the