@ -1,95 +1,9 @@
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
======== . -----. ========
======== . ----------------------. | === | ========
======== | . - " " " " " " " " " " " " " " " " " " - . | |-----| ========
======== || || | === | ========
======== || KICKSTART.NVIM || |-----| ========
======== || || | === | ========
======== || || |-----| ========
======== || : Tutor || | :: :: : | ========
======== | ' -..................- ' | | ____o | ========
======== ` " " ) ----------------(""` ___________ ========
======== / :: :: :: :: :: | | :: :: :: :: :: \ \ no mouse \ ========
======== / :: : = = = = = = = = | | = = hjkl = = :: : \ \ required \ ========
======== ' """""""""""" ' ' """""""""""" ' ' """""""""" ' ========
======== ========
=====================================================================
=====================================================================
What is Kickstart ?
Kickstart.nvim is * not * a distribution .
Kickstart.nvim is a starting point for your own configuration .
The goal is that you can read every line of code , top - to - bottom , understand
what your configuration is doing , and modify it to suit your needs .
Once you ' ve done that, you can start exploring, configuring and tinkering to
make Neovim your own ! That might mean leaving Kickstart just the way it is for a while
or immediately breaking it into modular pieces . It ' s up to you!
If you don ' t know anything about Lua, I recommend taking some time to read through
a guide . One possible example which will only take 10 - 15 minutes :
- https : // learnxinyminutes.com / docs / lua /
After understanding a bit more about Lua , you can use ` : help lua - guide ` as a
reference for how Neovim integrates Lua .
- : help lua - guide
- ( or HTML version ) : https : // neovim.io / doc / user / lua - guide.html
Kickstart Guide :
TODO : The very first thing you should do is to run the command ` : Tutor ` in Neovim .
If you don ' t know what this means, type the following:
- < escape key >
- :
- Tutor
- < enter key >
( If you already know the Neovim basics , you can skip this step . )
Once you ' ve completed that, you can continue working through **AND READING** the rest
of the kickstart init.lua .
Next , run AND READ ` : help ` .
This will open up a help window with some basic information
about reading , navigating and searching the builtin help documentation .
This should be the first place you go to look when you ' re stuck or confused
with something . It ' s one of my favorite Neovim features.
MOST IMPORTANTLY , we provide a keymap " <space>sh " to [ s ] earch the [ h ] elp documentation ,
which is very useful when you ' re not exactly sure of what you ' re looking for .
I have left several ` : help X ` comments throughout the init.lua
These are hints about where to find more information about the relevant settings ,
plugins or Neovim features used in Kickstart .
NOTE : Look for lines like this
Throughout the file . These are for you , the reader , to help you understand what is happening .
Feel free to delete them once you know what you ' re doing, but they should serve as a guide
for when you are first encountering a few different constructs in your Neovim config .
If you experience any errors while trying to install kickstart , run ` : checkhealth ` for more info .
I hope you enjoy your Neovim journey ,
- TJ
P.S . You can delete this when you ' re done too. It ' s your config now ! : )
--]]
-- Prepend mise shims to PATH so Mason/LSP can find node, go, etc.
vim.env . PATH = vim.env . HOME .. ' /.local/share/mise/shims: ' .. vim.env . PATH
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
-- Must happen before plugins are loaded.
vim.g . mapleader = ' '
vim.g . maplocalleader = ' '
@ -98,12 +12,9 @@ vim.g.have_nerd_font = false
-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
-- Make line numbers default
vim.o . number = true
-- You can also add relative line numbers, to help with jumping.
vim.o . relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
@ -189,6 +100,14 @@ vim.o.scrolloff = 10
-- See `:help 'confirm'`
vim.o . confirm = true
-- Modern UI defaults and safer project-local behavior.
vim.o . winborder = ' rounded '
vim.o . pumborder = ' rounded '
vim.o . pummaxwidth = 80
vim.o . smoothscroll = true
vim.o . modeline = false
vim.o . jumpoptions = ' clean,view '
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
@ -198,27 +117,40 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic Config & Keymaps
-- See :help vim.diagnostic.Opts
local function diagnostic_on_jump ( diagnostic )
if diagnostic then vim.diagnostic . open_float { scope = ' cursor ' , focus = false } end
end
vim.diagnostic . config {
update_in_insert = false ,
severity_sort = true ,
float = { border = ' rounded ' , source = ' if_many ' } ,
underline = { severity = { min = vim.diagnostic . severity.WARN } } ,
-- Can switch between these as you prefer
virtual_text = true , -- Text shows up at the end of the line
virtual_lines = false , -- Text shows up underneath the line, with virtual lines
-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
jump = { float = true } ,
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 ,
severity = { min = vim.diagnostic . severity.WARN } ,
format = function ( diagnostic )
if diagnostic.severity == vim.diagnostic . severity.WARN then return ' W: ' .. diagnostic.message end
if diagnostic.severity == vim.diagnostic . severity.ERROR then return ' E: ' .. diagnostic.message end
return nil
end ,
} ,
virtual_lines = false ,
jump = { on_jump = diagnostic_on_jump } ,
}
vim.keymap . set ( ' n ' , ' <leader>q ' , vim.diagnostic . setloclist , { desc = ' Open diagnostic [Q]uickfix list ' } )
vim.keymap . set ( ' n ' , ' [d ' , function ( )
vim.diagnostic . jump { count = - 1 , float = true }
end , { desc = ' Go to previous [D]iagnostic ' } )
vim.keymap . set ( ' n ' , ' ]d ' , function ( )
vim.diagnostic . jump { count = 1 , float = true }
end , { desc = ' Go to next [D]iagnostic ' } )
vim.keymap . set ( ' n ' , ' [d ' , function ( ) vim.diagnostic . jump { count = - 1 } end , { desc = ' Go to previous [D]iagnostic ' } )
vim.keymap . set ( ' n ' , ' ]d ' , function ( ) vim.diagnostic . jump { count = 1 } end , { desc = ' Go to next [D]iagnostic ' } )
vim.keymap . set ( ' n ' , ' <leader>de ' , vim.diagnostic . open_float , { desc = ' Show [D]iagnostic [E]rror details ' } )
vim.keymap . set ( ' n ' , ' <leader>dy ' , function ( )
local line = vim.api . nvim_win_get_cursor ( 0 ) [ 1 ]
@ -279,9 +211,7 @@ vim.keymap.set('n', '<leader>wk', '<C-w><C-k>', { desc = 'Move focus to the uppe
vim.api . nvim_create_autocmd ( ' TextYankPost ' , {
desc = ' Highlight when yanking (copying) text ' ,
group = vim.api . nvim_create_augroup ( ' kickstart-highlight-yank ' , { clear = true } ) ,
callback = function ( )
vim.hl . on_yank ( )
end ,
callback = function ( ) vim.hl . on_yank ( ) end ,
} )
local path_on_save_group = vim.api . nvim_create_augroup ( ' kickstart-create-path-on-save ' , { clear = true } )
@ -296,44 +226,32 @@ local is_in_allowed_root = function(path)
local abs_path = vim.fn . fnamemodify ( path , ' :p ' )
for _ , root in ipairs ( path_create_roots ) do
local abs_root = vim.fn . fnamemodify ( root , ' :p ' )
if abs_path : sub ( 1 , # abs_root ) == abs_root then
return true
end
if abs_path : sub ( 1 , # abs_root ) == abs_root then return true end
end
return false
end
local ensure_owner_rwx = function ( path )
local perms = vim.fn . getfperm ( path )
if perms ~= ' ' and perms : sub ( 1 , 3 ) ~= ' rwx ' then
vim.fn . setfperm ( path , ' rwx ' .. perms : sub ( 4 ) )
end
if perms ~= ' ' and perms : sub ( 1 , 3 ) ~= ' rwx ' then vim.fn . setfperm ( path , ' rwx ' .. perms : sub ( 4 ) ) end
end
vim.api . nvim_create_autocmd ( ' BufWritePre ' , {
desc = ' Create missing parent directories on save ' ,
group = path_on_save_group ,
callback = function ( args )
if vim.bo [ args.buf ] . buftype ~= ' ' then
return
end
if vim.bo [ args.buf ] . buftype ~= ' ' then return end
local file_path = vim.api . nvim_buf_get_name ( args.buf )
if file_path == ' ' or file_path : match ' ^%w+:// ' then
return
end
if file_path == ' ' or file_path : match ' ^%w+:// ' then return end
local uv = vim.uv or vim.loop
local abs_path = vim.fn . fnamemodify ( file_path , ' :p ' )
if not is_in_allowed_root ( abs_path ) then
return
end
if not is_in_allowed_root ( abs_path ) then return end
local parent = vim.fn . fnamemodify ( abs_path , ' :h ' )
if uv.fs_stat ( parent ) == nil then
vim.fn . mkdir ( parent , ' p ' , ' 0700 ' )
end
if uv.fs_stat ( parent ) == nil then vim.fn . mkdir ( parent , ' p ' , ' 0700 ' ) end
ensure_owner_rwx ( parent )
end ,
} )
@ -366,61 +284,19 @@ local treesitter_parsers = {
}
-- [[ Configure and install plugins ]]
--
-- To check the current status of your plugins, run
-- :Lazy
--
-- You can press `?` in this menu for help. Use `:q` to close the window
--
-- To update plugins you can run
-- :Lazy update
--
-- NOTE: Here is where you install your plugins.
require ( ' lazy ' ) . setup ( {
-- NOTE: Plugins can be added via a link or github org/name. To run setup automatically, use `opts = {}`
{ ' NMAC427/guess-indent.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`.
--
-- See `:help gitsigns` to understand what the configuration keys do
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
--
-- This is often very useful to both group configuration, as well as handle
-- lazy loading plugins that don't need to be loaded immediately at startup.
--
-- For example, in the following configuration, we use:
-- event = 'VimEnter'
--
-- 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 `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 ' ,
---@module 'which-key'
---@type wk.Opts
---@diagnostic disable-next-line: missing-fields
opts = {
-- delay between pressing a key and opening which-key (milliseconds)
delay = 0 ,
icons = { mappings = vim.g . have_nerd_font } ,
-- Document existing key chains
spec = {
{ ' <leader>a ' , group = ' Harpoon [A]dd ' } ,
{ ' <leader>c ' , group = ' [C]Make ' } ,
@ -435,92 +311,36 @@ require('lazy').setup({
{ ' <leader>w ' , group = ' [W]indow ' } ,
{ ' <leader>x ' , group = ' Trouble ' } ,
{ ' <leader>j ' , group = ' [J]ump ' } ,
{ ' <leader>h ' , group = ' Git [H]unk ' , mode = { ' n ' , ' v ' } } , -- Enable gitsigns recommended keymaps first
{ ' <leader>h ' , group = ' Git [H]unk ' , mode = { ' n ' , ' v ' } } ,
{ ' gr ' , group = ' LSP Actions ' , mode = { ' n ' } } ,
} ,
} ,
} ,
-- NOTE: Plugins can specify dependencies.
--
-- The dependencies are proper plugin specifications as well - anything
-- you do for a plugin at the top level, you can do for a dependency.
--
-- Use the `dependencies` key to specify the dependencies of a particular plugin
{ -- Fuzzy Finder (files, lsp, etc)
' nvim-telescope/telescope.nvim ' ,
-- By default, Telescope is included and acts as your picker for everything.
-- If you would like to switch to a different picker (like snacks, or fzf-lua)
-- you can disable the Telescope plugin by setting enabled to false and enable
-- your replacement picker by requiring it explicitly (e.g. 'custom.plugins.snacks')
-- Note: If you customize your config for yourself,
-- it’ s best to remove the Telescope plugin config entirely
-- instead of just disabling it here, to keep your config clean.
enabled = true ,
event = ' VimEnter ' ,
dependencies = {
' nvim-lua/plenary.nvim ' ,
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
{
' nvim-telescope/telescope-fzf-native.nvim ' ,
-- `build` is used to run some command when the plugin is installed/updated.
-- This is only run then, not every time Neovim starts up.
build = ' make ' ,
-- `cond` is a condition used to determine whether this plugin should be
-- installed and loaded.
cond = function ( ) return vim.fn . executable ' make ' == 1 end ,
} ,
{ ' nvim-telescope/telescope-ui-select.nvim ' } ,
-- Useful for getting pretty icons, but requires a Nerd Font.
{ ' nvim-tree/nvim-web-devicons ' , enabled = vim.g . have_nerd_font } ,
} ,
config = function ( )
-- Telescope is a fuzzy finder that comes with a lot of different things that
-- it can fuzzy find! It's more than just a "file finder", it can search
-- many different aspects of Neovim, your workspace, LSP, and more!
--
-- The easiest way to use Telescope, is to start by doing something like:
-- :Telescope help_tags
--
-- After running this command, a window will open up and you're able to
-- type in the prompt window. You'll see a list of `help_tags` options and
-- a corresponding preview of the help.
--
-- Two important keymaps to use while in Telescope are:
-- - Insert mode: <c-/>
-- - Normal mode: ?
--
-- This opens a window that shows you all of the keymaps for the current
-- Telescope picker. This is really useful to discover what Telescope can
-- do as well as how to actually do it!
-- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
require ( ' telescope ' ) . setup {
-- You can put your default mappings / updates / etc. in here
-- All the info you're looking for is in `:help telescope.setup()`
--
-- defaults = {
-- mappings = {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },
-- pickers = {}
extensions = {
[ ' ui-select ' ] = { require ( ' telescope.themes ' ) . get_dropdown ( ) } ,
} ,
}
-- Enable Telescope extensions if they are installed
pcall ( require ( ' telescope ' ) . load_extension , ' fzf ' )
pcall ( require ( ' telescope ' ) . load_extension , ' ui-select ' )
-- See `:help telescope.builtin`
local builtin = require ' telescope.builtin '
vim.keymap . set ( ' n ' , ' <leader>sh ' , builtin.help_tags , { desc = ' [S]earch [H]elp ' } )
vim.keymap . set ( ' n ' , ' <leader>sk ' , builtin.keymaps , { desc = ' [S]earch [K]eymaps ' } )
@ -534,51 +354,18 @@ require('lazy').setup({
vim.keymap . set ( ' n ' , ' <leader>sc ' , builtin.commands , { desc = ' [S]earch [C]ommands ' } )
vim.keymap . set ( ' n ' , ' <leader><leader> ' , builtin.buffers , { desc = ' [ ] Find existing buffers ' } )
-- This runs on LSP attach per buffer (see main LSP attach function in 'neovim/nvim-lspconfig' config for more info,
-- it is better explained there). This allows easily switching between pickers if you prefer using something else!
vim.api . nvim_create_autocmd ( ' LspAttach ' , {
group = vim.api . nvim_create_augroup ( ' telescope-lsp-attach ' , { clear = true } ) ,
callback = function ( event )
local buf = event.buf
-- Find references for the word under your cursor.
vim.keymap . set ( ' n ' , ' grr ' , builtin.lsp_references , { buffer = buf , desc = ' [G]oto [R]eferences ' } )
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
vim.keymap . set ( ' n ' , ' gri ' , builtin.lsp_implementations , { buffer = buf , desc = ' [G]oto [I]mplementation ' } )
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
vim.keymap . set ( ' n ' , ' grd ' , builtin.lsp_definitions , { buffer = buf , desc = ' [G]oto [D]efinition ' } )
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
vim.keymap . set ( ' n ' , ' gO ' , builtin.lsp_document_symbols , { buffer = buf , desc = ' Open Document Symbols ' } )
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
vim.keymap . set ( ' n ' , ' gW ' , builtin.lsp_dynamic_workspace_symbols , { buffer = buf , desc = ' Open Workspace Symbols ' } )
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
vim.keymap . set ( ' n ' , ' grt ' , builtin.lsp_type_definitions , { buffer = buf , desc = ' [G]oto [T]ype Definition ' } )
vim.keymap . set (
' n ' ,
' <leader>/ ' ,
function ( )
builtin.current_buffer_fuzzy_find ( require ( ' telescope.themes ' ) . get_dropdown {
winblend = 10 ,
previewer = false ,
} )
end ,
} )
{ desc = ' [/] Fuzzily search in current buffer ' }
)
-- Override default behavior and theme when searching
vim.keymap . set ( ' n ' , ' <leader>/ ' , function ( )
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find ( require ( ' telescope.themes ' ) . get_dropdown {
winblend = 10 ,
previewer = false ,
} )
end , { desc = ' [/] Fuzzily search in current buffer ' } )
-- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap . set (
' n ' ,
' <leader>s/ ' ,
@ -591,19 +378,13 @@ require('lazy').setup({
{ desc = ' [S]earch [/] in Open Files ' }
)
-- Shortcut for searching your Neovim configuration files
vim.keymap . set ( ' n ' , ' <leader>sn ' , function ( ) builtin.find_files { cwd = vim.fn . stdpath ' config ' } end , { desc = ' [S]earch [N]eovim files ' } )
end ,
} ,
-- LSP Plugins
{
-- Main LSP Configuration
' neovim/nvim-lspconfig ' ,
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
-- 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({})`
{
' mason-org/mason.nvim ' ,
---@module 'mason.settings'
@ -611,117 +392,37 @@ require('lazy').setup({
---@diagnostic disable-next-line: missing-fields
opts = { } ,
} ,
-- Maps LSP server names between nvim-lspconfig and Mason package names.
' mason-org/mason-lspconfig.nvim ' ,
' WhoIsSethDaniel/mason-tool-installer.nvim ' ,
-- Useful status updates for LSP.
{ ' j-hui/fidget.nvim ' , opts = { } } ,
} ,
config = function ( )
-- Brief aside: **What is LSP?**
--
-- LSP is an initialism you've probably heard, but might not understand what it is.
--
-- LSP stands for Language Server Protocol. It's a protocol that helps editors
-- and language tooling communicate in a standardized fashion.
--
-- In general, you have a "server" which is some tool built to understand a particular
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
-- processes that communicate with some "client" - in this case, Neovim!
--
-- LSP provides Neovim with features like:
-- - Go to definition
-- - Find references
-- - Autocompletion
-- - Symbol Search
-- - and more!
--
-- Thus, Language Servers are external tools that must be installed separately from
-- Neovim. This is where `mason` and related plugins come into play.
--
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
-- and elegantly composed help section, `:help lsp-vs-treesitter`
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- function will be executed to configure the current buffer
vim.api . nvim_create_autocmd ( ' LspAttach ' , {
group = vim.api . nvim_create_augroup ( ' kickstart-lsp-attach ' , { clear = true } ) ,
callback = function ( event )
-- NOTE: Remember that Lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself.
--
-- 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 , mode )
mode = mode or ' n '
vim.keymap . set ( mode , keys , func , { buffer = event.buf , desc = ' LSP: ' .. desc } )
end
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
local builtin = require ' telescope.builtin '
local client = vim.lsp . get_client_by_id ( event.data . client_id )
map ( ' grn ' , vim.lsp . buf.rename , ' [R]e[n]ame ' )
-- 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 ( ' gra ' , vim.lsp . buf.code_action , ' [G]oto Code [A]ction ' , { ' n ' , ' x ' } )
-- Find references for the word under your cursor.
map ( ' grr ' , require ( ' telescope.builtin ' ) . lsp_references , ' [G]oto [R]eferences ' )
map ( ' <leader>gr ' , require ( ' telescope.builtin ' ) . lsp_references , ' [G]oto [R]eferences ' )
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map ( ' gri ' , require ( ' telescope.builtin ' ) . lsp_implementations , ' [G]oto [I]mplementation ' )
map ( ' <leader>gi ' , require ( ' telescope.builtin ' ) . lsp_implementations , ' [G]oto [I]mplementation ' )
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
map ( ' grd ' , require ( ' telescope.builtin ' ) . lsp_definitions , ' [G]oto [D]efinition ' )
map ( ' <leader>gd ' , require ( ' telescope.builtin ' ) . lsp_definitions , ' [G]oto [D]efinition ' )
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map ( ' grr ' , builtin.lsp_references , ' [G]oto [R]eferences ' )
map ( ' <leader>gr ' , builtin.lsp_references , ' [G]oto [R]eferences ' )
map ( ' gri ' , builtin.lsp_implementations , ' [G]oto [I]mplementation ' )
map ( ' <leader>gi ' , builtin.lsp_implementations , ' [G]oto [I]mplementation ' )
map ( ' grd ' , builtin.lsp_definitions , ' [G]oto [D]efinition ' )
map ( ' <leader>gd ' , builtin.lsp_definitions , ' [G]oto [D]efinition ' )
map ( ' grD ' , vim.lsp . buf.declaration , ' [G]oto [D]eclaration ' )
map ( ' <leader>gD ' , vim.lsp . buf.declaration , ' [G]oto [D]eclaration ' )
map ( ' gO ' , builtin.lsp_document_symbols , ' Open Document Symbols ' )
map ( ' gW ' , builtin.lsp_dynamic_workspace_symbols , ' Open Workspace Symbols ' )
map ( ' grt ' , builtin.lsp_type_definitions , ' [G]oto [T]ype Definition ' )
map ( ' <leader>gt ' , builtin.lsp_type_definitions , ' [G]oto [T]ype Definition ' )
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map ( ' gO ' , require ( ' telescope.builtin ' ) . lsp_document_symbols , ' Open Document Symbols ' )
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
map ( ' gW ' , require ( ' telescope.builtin ' ) . lsp_dynamic_workspace_symbols , ' Open Workspace Symbols ' )
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map ( ' grt ' , require ( ' telescope.builtin ' ) . lsp_type_definitions , ' [G]oto [T]ype Definition ' )
map ( ' <leader>gt ' , require ( ' telescope.builtin ' ) . lsp_type_definitions , ' [G]oto [T]ype Definition ' )
-- 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 : supports_method ( ' 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 ' } , {
@ -745,55 +446,18 @@ require('lazy').setup({
} )
end
-- The following code creates a keymap to toggle 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 : supports_method ( ' textDocument/inlayHint ' , event.buf ) then
map ( ' <leader>th ' , function ( ) vim.lsp . inlay_hint.enable ( not vim.lsp . inlay_hint.is_enabled { bufnr = event.buf } ) end , ' [T]oggle Inlay [H]ints ' )
end
if client and client : supports_method ( ' textDocument/codeLens ' , event.buf ) then vim.lsp . codelens.enable ( true , { bufnr = event.buf } ) end
if client and client : supports_method ( ' textDocument/linkedEditingRange ' , event.buf ) then
vim.lsp . linked_editing_range.enable ( true , { client_id = client.id } )
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 ,
severity = { min = vim.diagnostic . severity.WARN } ,
format = function ( diagnostic )
if diagnostic.severity == vim.diagnostic . severity.WARN then
return ' W: ' .. diagnostic.message
end
if diagnostic.severity == vim.diagnostic . severity.ERROR then
return ' E: ' .. diagnostic.message
end
return nil
end ,
} ,
}
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
-- Add any additional override configuration in the following tables. Available keys are:
-- - cmd (table): Override the default command used to start the server
-- - filetypes (table): Override the default list of associated filetypes for the server
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local vue_language_server_path = vim.fn . stdpath ' data ' .. ' /mason/packages/vue-language-server/node_modules/@vue/language-server '
local vue_typescript_plugin = {
name = ' @vue/typescript-plugin ' ,
@ -844,20 +508,14 @@ require('lazy').setup({
elixirls = { } ,
gh_actions_ls = { } ,
lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = ' Replace ' ,
} ,
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
} ,
} ,
} ,
-- Tools
eslint = { } ,
astro = { } ,
vue_ls = { } ,
@ -875,14 +533,6 @@ require('lazy').setup({
postgres_lsp = { } ,
neocmake = { } ,
buf_ls = { } ,
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- 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_ls`) will work just fine
--
}
if has_go then
@ -900,9 +550,7 @@ require('lazy').setup({
}
end
if vim.fn . executable ' jq-lsp ' == 1 then
servers.jqls = { }
end
if vim.fn . executable ' jq-lsp ' == 1 then servers.jqls = { } end
servers.marksman . filetypes = { ' markdown ' , ' mdx ' }
servers.tailwindcss . filetypes = {
@ -928,19 +576,10 @@ require('lazy').setup({
automatic_enable = vim.tbl_keys ( servers or { } ) ,
}
-- 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
-- :Mason
--
-- You can press `g?` for help in this menu.
local ensure_installed = vim.tbl_filter ( function ( server_name )
return server_name ~= ' gopls ' and server_name ~= ' jqls '
end , vim.tbl_keys ( servers or { } ) )
local ensure_installed = vim.tbl_filter ( function ( server_name ) return server_name ~= ' gopls ' and server_name ~= ' jqls ' end , vim.tbl_keys ( servers or { } ) )
vim.list_extend ( ensure_installed , {
' stylua ' , -- Used to format Lua code
' markdownlint ' , -- Used by nvim-lint for Markdown buffers
' stylua ' ,
' markdownlint ' ,
' prettierd ' ,
' prettier ' ,
' clang-format ' ,
@ -952,14 +591,9 @@ require('lazy').setup({
require ( ' mason-tool-installer ' ) . setup { ensure_installed = ensure_installed }
-- Installed LSPs are configured and enabled automatically with mason-lspconfig
-- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
for server_name , config in pairs ( servers ) do
vim.lsp . config ( server_name , config )
end
-- NOTE: Some servers may require an old setup until they are updated. For the full list refer here: https://github.com/neovim/nvim-lspconfig/issues/3705
-- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
end ,
} ,
@ -980,9 +614,6 @@ require('lazy').setup({
opts = {
notify_on_error = false ,
format_on_save = function ( bufnr )
-- Disable "format_on_save lsp_fallback" for languages that don't
-- 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 }
if disable_filetypes [ vim.bo [ bufnr ] . filetype ] then
return nil
@ -1004,11 +635,6 @@ require('lazy').setup({
yaml = { ' prettierd ' , ' prettier ' , stop_after_first = true } ,
c = { ' clang_format ' } ,
cpp = { ' clang_format ' } ,
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
} ,
} ,
} ,
@ -1018,28 +644,13 @@ require('lazy').setup({
event = ' VimEnter ' ,
version = ' 1.* ' ,
dependencies = {
-- Snippet Engine
{
' L3MON4D3/LuaSnip ' ,
version = ' 2.* ' ,
build = ( function ( )
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn . has ' win32 ' == 1 or vim.fn . executable ' make ' == 0 then return end
return ' make install_jsregexp '
end ) ( ) ,
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
} ,
opts = { } ,
} ,
} ,
@ -1047,42 +658,14 @@ require('lazy').setup({
---@type blink.cmp.Config
opts = {
keymap = {
-- 'default' (recommended) for mappings similar to built-in completions
-- <c-y> to accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
-- 'super-tab' for tab to accept
-- 'enter' for enter to accept
-- 'none' for no mappings
--
-- For an understanding of why the 'default' preset is recommended,
-- you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
--
-- All presets have the following mappings:
-- <tab>/<s-tab>: move to right/left of your snippet expansion
-- <c-space>: Open menu or open docs if already open
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
-- <c-e>: Hide menu
-- <c-k>: Toggle signature help
--
-- See :h blink-cmp-config-keymap for defining your own keymap
preset = ' default ' ,
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
} ,
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = ' mono ' ,
} ,
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = false , auto_show_delay_ms = 500 } ,
} ,
@ -1092,27 +675,15 @@ require('lazy').setup({
snippets = { preset = ' luasnip ' } ,
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
-- which automatically downloads a prebuilt binary when enabled.
--
-- By default, we use the Lua implementation instead, but you may enable
-- the rust implementation via `'prefer_rust_with_warning'`
--
-- See :h blink-cmp-config-fuzzy for more information
fuzzy = { implementation = ' lua ' } ,
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true } ,
} ,
} ,
{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is.
--
-- 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.
priority = 1000 ,
config = function ( )
---@diagnostic disable-next-line: missing-fields
require ( ' tokyonight ' ) . setup {
@ -1121,9 +692,6 @@ require('lazy').setup({
} ,
}
-- 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 '
end ,
} ,
@ -1142,43 +710,18 @@ require('lazy').setup({
{ -- Collection of various small independent plugins/modules
' nvim-mini/mini.nvim ' ,
config = function ( )
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
-- - ci' - [C]hange [I]nside [']quote
require ( ' mini.ai ' ) . setup { n_lines = 500 }
-- Add/delete/replace surroundings (brackets, quotes, etc.)
--
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] [']
require ( ' mini.surround ' ) . setup ( )
-- Delete buffers while preserving window layout.
local bufremove = require ' mini.bufremove '
bufremove.setup ( )
vim.keymap . set ( ' n ' , ' <leader>bd ' , function ( )
bufremove.delete ( 0 , false )
end , { desc = ' [B]uffer [D]elete ' } )
vim.keymap . set ( ' n ' , ' <leader>bd ' , function ( ) bufremove.delete ( 0 , false ) end , { desc = ' [B]uffer [D]elete ' } )
-- Simple and easy statusline.
-- You could remove this setup call if you don't like it,
-- and try some other statusline plugin
local statusline = require ' mini.statusline '
-- set use_icons to true if you have a Nerd Font
statusline.setup { use_icons = vim.g . have_nerd_font }
-- You can configure sections in the statusline by overriding their
-- default behavior. For example, here we set the section for
-- cursor location to LINE:COLUMN
---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function ( ) return ' %2l:%-2v ' end
-- ... and there is more!
-- Check out: https://github.com/nvim-mini/mini.nvim
end ,
} ,
@ -1193,11 +736,8 @@ require('lazy').setup({
end
local ok , treesitter = pcall ( require , ' nvim-treesitter ' )
if ok then
treesitter.install ( treesitter_parsers , { summary = true } ) : wait ( 300000 )
end
if ok then treesitter.install ( treesitter_parsers , { summary = true } ) : wait ( 300000 ) end
end ,
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
config = function ( )
local treesitter = require ' nvim-treesitter '
treesitter.setup ( )
@ -1213,33 +753,12 @@ require('lazy').setup({
vim.api . nvim_create_autocmd ( ' FileType ' , {
group = vim.api . nvim_create_augroup ( ' kickstart-treesitter ' , { clear = true } ) ,
callback = function ( )
pcall ( vim.treesitter . start )
end ,
callback = function ( ) pcall ( vim.treesitter . start ) end ,
} )
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 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.
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- 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.
{ 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
} , { ---@diagnostic disable-line: missing-fields
rocks = { enabled = false } ,
ui = {