@ -11,7 +11,7 @@
======== || || | === | ========
======== || || | === | ========
======== || || |-----| ========
======== || || |-----| ========
======== || : Tutor || | :: :: : | ========
======== || : Tutor || | :: :: : | ========
======== | ' -..................- ' | | ____ . | ========
======== | ' -..................- ' | | ____ o | ========
======== ` " " ) ----------------(""` ___________ ========
======== ` " " ) ----------------(""` ___________ ========
======== / :: :: :: :: :: | | :: :: :: :: :: \ \ no mouse \ ========
======== / :: :: :: :: :: | | :: :: :: :: :: \ \ no mouse \ ========
======== / :: : = = = = = = = = | | = = hjkl = = :: : \ \ required \ ========
======== / :: : = = = = = = = = | | = = hjkl = = :: : \ \ required \ ========
@ -20,25 +20,31 @@
=====================================================================
=====================================================================
=====================================================================
=====================================================================
Kickstart.nvim is * not * a distribution .
What is Kickstart ?
Kickstart.nvim is a template for your own configuration .
Kickstart.nvim is * not * a distribution .
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 should start exploring, configuring and tinkering to
Kickstart.nvim is a starting point for your own configuration .
explore Neovim !
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 .
If you don ' t know anything about Lua, I recommend taking some time to read through
Once you ' ve done that, you can start exploring, configuring and tinkering to
a guide . One possible example :
make Neovim your own ! That might mean leaving kickstart just the way it is for a while
- https : // learnxinyminutes.com / docs / lua /
or immediately breaking it into modular pieces . It ' s up to you!
And then you can explore or search through ` : help lua - guide `
If you don ' t know anything about Lua, I recommend taking some time to read through
- https : // neovim.io / doc / user / lua - guide.html
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 :
Kickstart Guide :
The very first thing you should do , is run the command ` : Tutor ` inside Neovim .
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:
If you don ' t know what this means, type the following:
- < escape key >
- < escape key >
- :
- :
@ -57,18 +63,21 @@ Kickstart Guide:
This should be the first place you go to look when you ' re stuck or confused
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.
with something . It ' s one of my favorite neovim features.
MOST IMPORTANTLY , we provide a keymap " < leader >sh" to [ s ] earch the [ h ] elp documentation ,
MOST IMPORTANTLY , we provide a keymap " < space >sh" to [ s ] earch the [ h ] elp documentation ,
which is very useful when you ' re not sure exactly what you ' re looking for .
which is very useful when you ' re not sure exactly what you ' re looking for .
I have left several ` : help X ` comments throughout the init.lua
I have left several ` : help X ` comments throughout the init.lua
You should run that command and read that help section for more information .
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
NOTE : Look for lines like this
Throughout the file . These are for you , the reader to help understand what is happening .
Throughout the file . These are for you , the reader , to help understand what is happening .
Feel free to delete them once you know what you ' re doing, but they should serve as a guide
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 nvim config .
for when you are first encountering a few different constructs in your nvim config .
If you experience any errors while trying to install kickstart , run ` : checkhealth ` for more info
I hope you enjoy your Neovim journey ,
I hope you enjoy your Neovim journey ,
- TJ
- TJ
@ -77,7 +86,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
-- Set <space> as the leader key
-- Set <space> as the leader key
-- See `:help mapleader`
-- See `:help mapleader`
-- NOTE: Must happen before plugins are requir ed (otherwise wrong leader will be used)
-- NOTE: Must happen before plugins are load ed (otherwise wrong leader will be used)
vim.g . mapleader = ' '
vim.g . mapleader = ' '
vim.g . maplocalleader = ' '
vim.g . maplocalleader = ' '
@ -92,9 +101,12 @@ vim.opt.number = true
-- Experiment for yourself to see if you like it!
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
-- vim.opt.relativenumber = true
-- Enable mouse mode
-- Enable mouse mode , can be useful for resizing splits for example!
vim.opt . mouse = ' a '
vim.opt . mouse = ' a '
-- Don't show the mode, since it's already in status line
vim.opt . showmode = false
-- Sync clipboard between OS and Neovim.
-- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
-- See `:help 'clipboard'`
@ -127,40 +139,60 @@ vim.opt.splitbelow = true
vim.opt . list = true
vim.opt . list = true
vim.opt . listchars = { tab = ' » ' , trail = ' · ' , nbsp = ' ␣ ' }
vim.opt . listchars = { tab = ' » ' , trail = ' · ' , nbsp = ' ␣ ' }
-- Preview substitutions live
-- Preview substitutions live , as you type!
vim.opt . inccommand = ' split '
vim.opt . inccommand = ' split '
-- [[ Basic Keymaps ]]
-- Show which line your cursor is on
vim.opt . cursorline = true
-- Set highlight on search
vim.opt . hlsearch = true
-- Clear highlighting on pressing Escape
-- Minimal number of screen lines to keep above and below the cursor.
vim. keymap. set ( ' n ' , ' <Esc> ' , ' <esc>:nohlsearch<CR> ' , { silent = true } )
vim. opt. scrolloff = 10
-- Keymaps for better default experience
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- See `:help vim.keymap.set()`
vim.keymap . set ( { ' n ' , ' v ' } , ' <Space> ' , ' <Nop> ' , { silent = true } )
-- Remap for dealing with word wrap
-- Set highlight on search, but clear on pressing <Esc> in normal mode
vim. keymap. set ( ' n ' , ' k ' , " v:count == 0 ? 'gk' : 'k' " , { expr = true , silent = true } )
vim. opt. hlsearch = true
vim.keymap . set ( ' n ' , ' j' , " v:count == 0 ? 'gj' : 'j' " , { expr = true , silent = true } )
vim.keymap . set ( ' n ' , ' <Esc>' , ' <cmd>nohlsearch<CR> ' )
-- Diagnostic keymaps
-- 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_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 ' , ' ]d ' , vim.diagnostic . goto_next , { desc = ' Go to next [D]iagnostic message ' } )
vim.keymap . set ( ' n ' , ' <leader>e ' , vim.diagnostic . open_float , { desc = ' Open floating diagnostic 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 s list' } )
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
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press < c-\><c -n>, which
-- for people to discover. Otherwise, you normally need to press < C-\><C -n>, which
-- is not what someone will guess without a bit more experience.
-- is not what someone will guess without a bit more experience.
vim.keymap . set ( ' t ' , ' <esc><esc> ' , ' <c- \\ ><c-n> ' , { desc = ' Escape Escape exits terminal mode ' } )
--
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- [[ Highlight on yank ]]
-- or just use <C-\><C-n> to exit terminal mode
-- See `:help vim.highlight.on_yank()`
vim.keymap . set ( ' t ' , ' <Esc><Esc> ' , ' <C- \\ ><C-n> ' , { desc = ' Exit terminal mode ' } )
-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap . set ( ' n ' , ' <C-h> ' , ' <C-w><C-h> ' , { desc = ' Move focus to the left window ' } )
vim.keymap . set ( ' n ' , ' <C-l> ' , ' <C-w><C-l> ' , { desc = ' Move focus to the right window ' } )
vim.keymap . set ( ' n ' , ' <C-j> ' , ' <C-w><C-j> ' , { desc = ' Move focus to the lower window ' } )
vim.keymap . set ( ' n ' , ' <C-k> ' , ' <C-w><C-k> ' , { desc = ' Move focus to the upper window ' } )
-- [[ Basic Autocommands ]]
-- See :help lua-guide-autocommands
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
vim.api . nvim_create_autocmd ( ' TextYankPost ' , {
vim.api . nvim_create_autocmd ( ' TextYankPost ' , {
group = vim.api . nvim_create_augroup ( ' YankHighlight ' , { clear = true } ) ,
desc = ' Highlight when yanking (copying) text ' ,
group = vim.api . nvim_create_augroup ( ' kickstart-highlight-yank ' , { clear = true } ) ,
callback = function ( )
callback = function ( )
vim.highlight . on_yank ( )
vim.highlight . on_yank ( )
end ,
end ,
@ -174,7 +206,7 @@ local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop . fs_stat ( lazypath ) then
if not vim.loop . fs_stat ( lazypath ) then
local lazyrepo = ' https://github.com/folke/lazy.nvim.git '
local lazyrepo = ' https://github.com/folke/lazy.nvim.git '
vim.fn . system { ' git ' , ' clone ' , ' --filter=blob:none ' , ' --branch=stable ' , lazyrepo , lazypath }
vim.fn . system { ' git ' , ' clone ' , ' --filter=blob:none ' , ' --branch=stable ' , lazyrepo , lazypath }
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt . rtp : prepend ( lazypath )
vim.opt . rtp : prepend ( lazypath )
-- [[ Configure and install plugins ]]
-- [[ Configure and install plugins ]]
@ -182,7 +214,7 @@ vim.opt.rtp:prepend(lazypath)
-- To check the current status of your plugins, run
-- To check the current status of your plugins, run
-- :Lazy
-- :Lazy
--
--
-- You can press `?` in this menu for help.
-- You can press `?` in this menu for help. Use `:q` to close the window
--
--
-- To update plugins, you can run
-- To update plugins, you can run
-- :Lazy update
-- :Lazy update
@ -206,32 +238,19 @@ require('lazy').setup({
{ ' numToStr/Comment.nvim ' , opts = { } } ,
{ ' numToStr/Comment.nvim ' , opts = { } } ,
-- Here is a more advanced example where we pass configuration
-- Here is a more advanced example where we pass configuration
-- options to `conform.nvim`.
-- options to `gitsigns.nvim`. This is equivalent to the following lua:
-- require('gitsigns').setup({ ... })
--
--
-- See `:help conform ` to understand what the configuration keys do
-- See `:help gitsigns ` to understand what the configuration keys do
{ -- A utoformat
{ -- A dds git related signs to the gutter, as well as utilities for managing changes
' stevearc/conform .nvim' ,
' lewis6991/gitsigns .nvim' ,
opts = {
opts = {
format_on_save = {
signs = {
timeout_ms = 500 ,
add = { text = ' + ' } ,
lsp_fallback = true ,
change = { text = ' ~ ' } ,
} ,
delete = { text = ' _ ' } ,
formatters_by_ft = {
topdelete = { text = ' ‾ ' } ,
lua = { ' stylua ' } ,
changedelete = { text = ' ~ ' } ,
-- 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" } },
templ = { ' templ ' } ,
} ,
formatters = {
templ = {
cmd = ' templ ' ,
args = { ' fmt ' } ,
stdin = true ,
} ,
} ,
} ,
} ,
} ,
} ,
} ,
@ -257,15 +276,12 @@ require('lazy').setup({
config = function ( ) -- This is the function that runs, AFTER loading
config = function ( ) -- This is the function that runs, AFTER loading
require ( ' which-key ' ) . setup ( )
require ( ' which-key ' ) . setup ( )
-- d ocument existing key chains
-- D ocument existing key chains
require ( ' which-key ' ) . register {
require ( ' which-key ' ) . register {
[ ' <leader>c ' ] = { name = ' [C]ode ' , _ = ' which_key_ignore ' } ,
[ ' <leader>c ' ] = { name = ' [C]ode ' , _ = ' which_key_ignore ' } ,
[ ' <leader>d ' ] = { name = ' [D]ocument ' , _ = ' which_key_ignore ' } ,
[ ' <leader>d ' ] = { name = ' [D]ocument ' , _ = ' which_key_ignore ' } ,
[ ' <leader>g ' ] = { name = ' [G]it ' , _ = ' which_key_ignore ' } ,
[ ' <leader>h ' ] = { name = ' Git [H]unk ' , _ = ' which_key_ignore ' } ,
[ ' <leader>r ' ] = { name = ' [R]ename ' , _ = ' which_key_ignore ' } ,
[ ' <leader>r ' ] = { name = ' [R]ename ' , _ = ' which_key_ignore ' } ,
[ ' <leader>s ' ] = { name = ' [S]earch ' , _ = ' which_key_ignore ' } ,
[ ' <leader>s ' ] = { name = ' [S]earch ' , _ = ' which_key_ignore ' } ,
[ ' <leader>t ' ] = { name = ' [T]oggle ' , _ = ' which_key_ignore ' } ,
[ ' <leader>w ' ] = { name = ' [W]orkspace ' , _ = ' which_key_ignore ' } ,
[ ' <leader>w ' ] = { name = ' [W]orkspace ' , _ = ' which_key_ignore ' } ,
}
}
end ,
end ,
@ -370,7 +386,7 @@ require('lazy').setup({
end , { desc = ' [/] Fuzzily search in current buffer ' } )
end , { desc = ' [/] Fuzzily search in current buffer ' } )
-- Also possible to pass additional configuration options.
-- Also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular picker s
-- See `:help telescope.builtin.live_grep()` for information about particular key s
vim.keymap . set ( ' n ' , ' <leader>s/ ' , function ( )
vim.keymap . set ( ' n ' , ' <leader>s/ ' , function ( )
builtin.live_grep {
builtin.live_grep {
grep_open_files = true ,
grep_open_files = true ,
@ -380,9 +396,7 @@ require('lazy').setup({
-- Shortcut for searching your neovim configuration files
-- Shortcut for searching your neovim configuration files
vim.keymap . set ( ' n ' , ' <leader>sn ' , function ( )
vim.keymap . set ( ' n ' , ' <leader>sn ' , function ( )
builtin.find_files {
builtin.find_files { cwd = vim.fn . stdpath ' config ' }
cwd = vim.fn . stdpath ' config ' ,
}
end , { desc = ' [S]earch [N]eovim files ' } )
end , { desc = ' [S]earch [N]eovim files ' } )
end ,
end ,
} ,
} ,
@ -390,7 +404,7 @@ require('lazy').setup({
{ -- LSP Configuration & Plugins
{ -- LSP Configuration & Plugins
' neovim/nvim-lspconfig ' ,
' neovim/nvim-lspconfig ' ,
dependencies = {
dependencies = {
-- Automatically install LSPs to stdpath for neovim
-- Automatically install LSPs and related tools to stdpath for neovim
' williamboman/mason.nvim ' ,
' williamboman/mason.nvim ' ,
' williamboman/mason-lspconfig.nvim ' ,
' williamboman/mason-lspconfig.nvim ' ,
' WhoIsSethDaniel/mason-tool-installer.nvim ' ,
' WhoIsSethDaniel/mason-tool-installer.nvim ' ,
@ -423,7 +437,7 @@ require('lazy').setup({
-- - and more!
-- - and more!
--
--
-- Thus, Language Servers are external tools that must be installed separately from
-- Thus, Language Servers are external tools that must be installed separately from
-- Neovim. This is where `mason` and `mason-lspconfig` both come into play.
-- 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
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
-- and elegantly composed help section, :help lsp-vs-treesitter
-- and elegantly composed help section, :help lsp-vs-treesitter
@ -437,7 +451,7 @@ require('lazy').setup({
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- function will be executed to configure the current buffer
-- function will be executed to configure the current buffer
vim.api . nvim_create_autocmd ( ' LspAttach ' , {
vim.api . nvim_create_autocmd ( ' LspAttach ' , {
group = vim.api . nvim_create_augroup ( ' custom -lsp-attach' , { clear = true } ) ,
group = vim.api . nvim_create_augroup ( ' kickstart -lsp-attach' , { clear = true } ) ,
callback = function ( event )
callback = function ( event )
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- 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
-- to define small helper and utility functions so you don't have to repeat yourself
@ -449,43 +463,73 @@ require('lazy').setup({
vim.keymap . set ( ' n ' , keys , func , { buffer = event.buf , desc = ' LSP: ' .. desc } )
vim.keymap . set ( ' n ' , keys , func , { buffer = event.buf , desc = ' LSP: ' .. desc } )
end
end
-- Important LSP Navigation keybinds
--
-- Jump to the definition of the word under your cursor.
-- 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>.
-- To jump back, press <C-T>.
map ( ' gd ' , require ( ' telescope.builtin ' ) . lsp_definitions , ' [G]oto [D]efinition ' )
map ( ' gd ' , require ( ' telescope.builtin ' ) . lsp_definitions , ' [G]oto [D]efinition ' )
-- Find references for the word under your cursor.
map ( ' gr ' , require ( ' telescope.builtin ' ) . lsp_references , ' [G]oto [R]eferences ' )
map ( ' 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 ( ' gI ' , require ( ' telescope.builtin ' ) . lsp_implementations , ' [G]oto [I]mplementation ' )
map ( ' gI ' , require ( ' telescope.builtin ' ) . lsp_implementations , ' [G]oto [I]mplementation ' )
-- 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 ( ' <leader>D ' , require ( ' telescope.builtin ' ) . lsp_type_definitions , ' Type [D]efinition ' )
map ( ' <leader>D ' , require ( ' telescope.builtin ' ) . lsp_type_definitions , ' Type [D]efinition ' )
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map ( ' <leader>ds ' , require ( ' telescope.builtin ' ) . lsp_document_symbols , ' [D]ocument [S]ymbols ' )
map ( ' <leader>ds ' , require ( ' telescope.builtin ' ) . lsp_document_symbols , ' [D]ocument [S]ymbols ' )
map ( ' <leader>ws ' , require ( ' telescope.builtin ' ) . lsp_dynamic_workspace_symbols , ' [W]orkspace [S]ymbols ' )
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- Fuzzy find all the symbols in your current workspace
-- For example, in C this would take you to the header
-- Similar to document symbols, except searches over your whole project.
map ( ' gD' , vim.lsp . buf.declaration , ' [G]oto [D]eclaration ' )
map ( ' <leader>ws' , require ( ' telescope.builtin ' ) . lsp_dynamic_workspace_symbols , ' [W]orkspace [S]ymbols ' )
-- Rename the variable under your cursor
-- Rename the variable under your cursor
-- Most Language Servers support renaming across files, etc.
map ( ' <leader>rn ' , vim.lsp . buf.rename , ' [R]e[n]ame ' )
map ( ' <leader>rn ' , vim.lsp . buf.rename , ' [R]e[n]ame ' )
-- Execute a code action, usually your cursor needs to be on top of an error
-- 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.
-- or a suggestion from your LSP for this to activate.
map ( ' <leader>ca ' , function ( )
map ( ' <leader>ca ' , vim.lsp . buf.code_action , ' [C]ode [A]ction ' )
vim.lsp . buf.code_action { context = { only = { ' quickfix ' , ' refactor ' , ' source ' } } }
end , ' [C]ode [A]ction ' )
-- See `:help K` for why this keymap
-- 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 ( ' K ' , vim.lsp . buf.hover , ' Hover Documentation ' )
-- Show the signature of the function you're currently completing.
-- WARN: This is not Goto Definition, this is Goto Declaration.
map ( ' <C-k> ' , vim.lsp . buf.signature_help , ' Signature Documentation ' )
-- For example, in C this would take you to the header
map ( ' gD ' , vim.lsp . buf.declaration , ' [G]oto [D]eclaration ' )
-- 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
vim.api . nvim_create_autocmd ( { ' CursorHold ' , ' CursorHoldI ' } , {
buffer = event.buf ,
callback = vim.lsp . buf.document_highlight ,
} )
vim.api . nvim_create_autocmd ( { ' CursorMoved ' , ' CursorMovedI ' } , {
buffer = event.buf ,
callback = vim.lsp . buf.clear_references ,
} )
end
end ,
end ,
} )
} )
-- LSP servers and clients are able to communicate to each other what features they support.
-- 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.
-- 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.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
-- So, we create new capabilties with nvim cmp, and then broadcast that to the servers.
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
local capabilities = require ( ' cmp_nvim_lsp ' ) . default_capabilities ( vim.lsp . protocol.make_client_capabilities ( ) )
local capabilities = vim.lsp . protocol.make_client_capabilities ( )
capabilities = vim.tbl_deep_extend ( ' force ' , capabilities , require ( ' cmp_nvim_lsp ' ) . default_capabilities ( ) )
-- Enable the following language servers
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
@ -530,8 +574,19 @@ require('lazy').setup({
-- capabilities = {},
-- capabilities = {},
settings = {
settings = {
Lua = {
Lua = {
workspace = { checkThirdParty = false } ,
runtime = { version = ' LuaJIT ' } ,
telemetry = { enable = false } ,
workspace = {
checkThirdParty = false ,
telemetry = { enable = false } ,
-- Tells lua_ls where to find all the Lua files that you have loaded
-- for your neovim configuration.
library = {
' ${3rd}/luv/library ' ,
unpack ( vim.api . nvim_get_runtime_file ( ' ' , true ) ) ,
} ,
-- If lua_ls is really slow on your computer, you can try this instead:
-- library = { vim.env.VIMRUNTIME },
} ,
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
-- diagnostics = { disable = { 'missing-fields' } },
} ,
} ,
@ -544,21 +599,22 @@ require('lazy').setup({
} ,
} ,
}
}
-- You can add other tools here that you want Mason to install
-- Ensure the servers and tools above are installed
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys ( servers or { } )
vim.list_extend ( ensure_installed , {
' stylua ' , -- Used to format lua code
} )
-- Ensure the servers above are installed
-- To check the current status of installed tools and/or manually install
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- other tools, you can run
-- :Mason
-- :Mason
--
--
-- You can press `g?` for help in this menu
-- You can press `g?` for help in this menu
require ( ' mason ' ) . setup ( )
require ( ' mason ' ) . setup ( )
-- 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 { } )
vim.list_extend ( ensure_installed , {
' stylua ' , -- Used to format lua code
} )
require ( ' mason-tool-installer ' ) . setup { ensure_installed = ensure_installed }
require ( ' mason-tool-installer ' ) . setup { ensure_installed = ensure_installed }
require ( ' mason-lspconfig ' ) . setup {
require ( ' mason-lspconfig ' ) . setup {
handlers = {
handlers = {
function ( server_name )
function ( server_name )
@ -567,6 +623,9 @@ require('lazy').setup({
cmd = server.cmd ,
cmd = server.cmd ,
settings = server.settings ,
settings = server.settings ,
filetypes = server.filetypes ,
filetypes = server.filetypes ,
-- 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 tsserver)
capabilities = vim.tbl_deep_extend ( ' force ' , { } , capabilities , server.capabilities or { } ) ,
capabilities = vim.tbl_deep_extend ( ' force ' , { } , capabilities , server.capabilities or { } ) ,
}
}
end ,
end ,
@ -575,6 +634,31 @@ require('lazy').setup({
end ,
end ,
} ,
} ,
{ -- Autoformat
' stevearc/conform.nvim ' ,
opts = {
notify_on_error = false ,
format_on_save = {
timeout_ms = 500 ,
lsp_fallback = true ,
} ,
formatters_by_ft = {
lua = { ' stylua ' } ,
-- 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" } },
templ = {
cmd = ' templ ' ,
args = { ' fmt ' } ,
stdin = true ,
} ,
} ,
} ,
} ,
{ -- Autocompletion
{ -- Autocompletion
' hrsh7th/nvim-cmp ' ,
' hrsh7th/nvim-cmp ' ,
event = ' InsertEnter ' ,
event = ' InsertEnter ' ,
@ -586,7 +670,7 @@ require('lazy').setup({
-- Build Step is needed for regex support in snippets
-- Build Step is needed for regex support in snippets
-- This step is not supported in many windows environments
-- This step is not supported in many windows environments
-- Remove the below condition to re-enable on windows
-- Remove the below condition to re-enable on windows
if vim.fn . has ' win32 ' == 1 then
if vim.fn . has ' win32 ' == 1 or vim.fn . executable ' make ' == 0 then
return
return
end
end
return ' make install_jsregexp '
return ' make install_jsregexp '
@ -594,18 +678,22 @@ require('lazy').setup({
} ,
} ,
' saadparwaiz1/cmp_luasnip ' ,
' saadparwaiz1/cmp_luasnip ' ,
-- Adds LSP completion capabilities
-- Adds other completion capabilities.
-- nvim-cmp does not ship with all sources by default. They are split
-- into multiple repos for maintenance purposes.
' hrsh7th/cmp-nvim-lsp ' ,
' hrsh7th/cmp-nvim-lsp ' ,
' hrsh7th/cmp-path ' ,
' hrsh7th/cmp-path ' ,
-- Adds a number of user-friendly snippets
-- If you want to add a bunch of pre-configured snippets,
' rafamadriz/friendly-snippets ' ,
-- you can use this plugin to help you. It even has snippets
-- for various frameworks/libraries/etc. but you will have to
-- set up the ones that are useful for you.
-- 'rafamadriz/friendly-snippets',
} ,
} ,
config = function ( )
config = function ( )
-- See `:help cmp`
-- See `:help cmp`
local cmp = require ' cmp '
local cmp = require ' cmp '
local luasnip = require ' luasnip '
local luasnip = require ' luasnip '
require ( ' luasnip.loaders.from_vscode ' ) . lazy_load ( )
luasnip.config . setup { }
luasnip.config . setup { }
cmp.setup {
cmp.setup {
@ -614,9 +702,8 @@ require('lazy').setup({
luasnip.lsp_expand ( args.body )
luasnip.lsp_expand ( args.body )
end ,
end ,
} ,
} ,
completion = {
completion = { completeopt = ' menu,menuone,noinsert ' } ,
completeopt = ' menu,menuone,noinsert,noselect ' ,
} ,
-- For an understanding of why these mappings were
-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
-- chosen, you will need to read `:help ins-completion`
--
--
@ -665,20 +752,6 @@ require('lazy').setup({
end ,
end ,
} ,
} ,
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
' lewis6991/gitsigns.nvim ' ,
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = ' + ' } ,
change = { text = ' ~ ' } ,
delete = { text = ' _ ' } ,
topdelete = { text = ' ‾ ' } ,
changedelete = { text = ' ~ ' } ,
} ,
} ,
} ,
{ -- You can easily change to a different colorscheme.
{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is
-- change the command in the config to whatever the name of that colorscheme is
@ -705,12 +778,13 @@ require('lazy').setup({
-- Better Around/Inside textobjects
-- Better Around/Inside textobjects
--
--
-- Examples:
-- Examples:
-- - ya) - [Y]ank [A]round [)]parenthen
-- - va) - [V]isually select [A]round [)]parenthen
-- - yinq - [Y]ank [I]nside [N]ext [']quote
-- - yinq - [Y]ank [I]nside [N]ext [']quote
-- - ci' - [C]hange [I]nside [']quote
-- - ci' - [C]hange [I]nside [']quote
require ( ' mini.ai ' ) . setup { n_lines = 500 }
require ( ' mini.ai ' ) . setup { n_lines = 500 }
-- Add/delete/replace surroundings (brackets, quotes, etc.)
-- Add/delete/replace surroundings (brackets, quotes, etc.)
--
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes
-- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] [']
-- - sr)' - [S]urround [R]eplace [)] [']
@ -734,19 +808,11 @@ require('lazy').setup({
---@diagnostic disable-next-line: missing-fields
---@diagnostic disable-next-line: missing-fields
require ( ' nvim-treesitter.configs ' ) . setup {
require ( ' nvim-treesitter.configs ' ) . setup {
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
ensure_installed = { ' bash ' , ' c ' , ' html ' , ' lua ' , ' markdown ' , ' vim ' , ' vimdoc ' } ,
-- Autoinstall languages that are not installed
auto_install = true ,
auto_install = true ,
highlight = { enable = true } ,
highlight = { enable = true } ,
indent = { enable = true } ,
indent = { enable = true } ,
incremental_selection = {
enable = true ,
keymaps = {
init_selection = ' gnn ' ,
node_incremental = ' grn ' ,
scope_incremental = ' grc ' ,
node_decremental = ' grm ' ,
} ,
} ,
}
}
-- There are additional nvim-treesitter modules that you can use to interact
-- There are additional nvim-treesitter modules that you can use to interact
@ -763,18 +829,23 @@ require('lazy').setup({
-- init.lua. If you want these files, they are in the repository, so you can just download them and
-- init.lua. If you want these files, they are in the repository, so you can just download them and
-- put them in the right spots if you want.
-- put them in the right spots if you want.
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
-- These are some example plugins that I've included in the kickstart repository.
-- init.lua. If you want these files, they are in the repository, so you can just download them and
-- Uncomment any of the lines below to enable them.
-- put them in the right spots if you want.
-- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart
--
-- Here are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.indent_line',
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
-- This is the easiest way to modularize your config.
-- up-to-date with whatever is in the kickstart repo.
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- 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 see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
{ import = ' custom.plugins ' } ,
{ import = ' custom.plugins ' } ,
} , { } )
} , { } )
@ -784,6 +855,7 @@ vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
group = git_group ,
group = git_group ,
pattern = vim.fn . expand ' COMMIT_EDITMSG ' ,
pattern = vim.fn . expand ' COMMIT_EDITMSG ' ,
} )
} )
} , { } )
-- The line beneath this is called `modeline`. See `:help modeline`
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
-- vim: ts=2 sts=2 sw=2 et