tidy and harden neovim config

This commit is contained in:
Paul B. Kim 2026-05-09 00:05:20 +09:00
parent 20fd850084
commit 37a75addf9
No known key found for this signature in database
9 changed files with 114 additions and 697 deletions

649
init.lua
View File

@ -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. -- 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 vim.env.PATH = vim.env.HOME .. '/.local/share/mise/shims:' .. vim.env.PATH
-- Set <space> as the leader key -- Set <space> as the leader key
-- See `:help mapleader` -- 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.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
@ -98,12 +12,9 @@ vim.g.have_nerd_font = false
-- [[ Setting options ]] -- [[ Setting options ]]
-- See `:help vim.o` -- 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 -- Make line numbers default
vim.o.number = true vim.o.number = true
-- You can also add relative line numbers, to help with jumping.
vim.o.relativenumber = true vim.o.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example! -- Enable mouse mode, can be useful for resizing splits for example!
@ -189,6 +100,14 @@ vim.o.scrolloff = 10
-- See `:help 'confirm'` -- See `:help 'confirm'`
vim.o.confirm = true 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 ]] -- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
@ -198,27 +117,40 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic Config & Keymaps -- Diagnostic Config & Keymaps
-- See :help vim.diagnostic.Opts -- 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 { vim.diagnostic.config {
update_in_insert = false, update_in_insert = false,
severity_sort = true, severity_sort = true,
float = { border = 'rounded', source = 'if_many' }, float = { border = 'rounded', source = 'if_many' },
underline = { severity = { min = vim.diagnostic.severity.WARN } }, underline = { severity = vim.diagnostic.severity.ERROR },
signs = vim.g.have_nerd_font and {
-- Can switch between these as you prefer text = {
virtual_text = true, -- Text shows up at the end of the line [vim.diagnostic.severity.ERROR] = '󰅚 ',
virtual_lines = false, -- Text shows up underneath the line, with virtual lines [vim.diagnostic.severity.WARN] = '󰀪 ',
[vim.diagnostic.severity.INFO] = '󰋽 ',
-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d` [vim.diagnostic.severity.HINT] = '󰌶 ',
jump = { float = true }, },
} 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', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
vim.keymap.set('n', '[d', function() vim.keymap.set('n', '[d', function() vim.diagnostic.jump { count = -1 } end, { desc = 'Go to previous [D]iagnostic' })
vim.diagnostic.jump { count = -1, float = true } vim.keymap.set('n', ']d', function() vim.diagnostic.jump { count = 1 } end, { desc = 'Go to next [D]iagnostic' })
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', '<leader>de', vim.diagnostic.open_float, { desc = 'Show [D]iagnostic [E]rror details' }) vim.keymap.set('n', '<leader>de', vim.diagnostic.open_float, { desc = 'Show [D]iagnostic [E]rror details' })
vim.keymap.set('n', '<leader>dy', function() vim.keymap.set('n', '<leader>dy', function()
local line = vim.api.nvim_win_get_cursor(0)[1] 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', { vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text', desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function() callback = function() vim.hl.on_yank() end,
vim.hl.on_yank()
end,
}) })
local path_on_save_group = vim.api.nvim_create_augroup('kickstart-create-path-on-save', { clear = true }) 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') local abs_path = vim.fn.fnamemodify(path, ':p')
for _, root in ipairs(path_create_roots) do for _, root in ipairs(path_create_roots) do
local abs_root = vim.fn.fnamemodify(root, ':p') local abs_root = vim.fn.fnamemodify(root, ':p')
if abs_path:sub(1, #abs_root) == abs_root then if abs_path:sub(1, #abs_root) == abs_root then return true end
return true
end
end end
return false return false
end end
local ensure_owner_rwx = function(path) local ensure_owner_rwx = function(path)
local perms = vim.fn.getfperm(path) local perms = vim.fn.getfperm(path)
if perms ~= '' and perms:sub(1, 3) ~= 'rwx' then if perms ~= '' and perms:sub(1, 3) ~= 'rwx' then vim.fn.setfperm(path, 'rwx' .. perms:sub(4)) end
vim.fn.setfperm(path, 'rwx' .. perms:sub(4))
end
end end
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
desc = 'Create missing parent directories on save', desc = 'Create missing parent directories on save',
group = path_on_save_group, group = path_on_save_group,
callback = function(args) callback = function(args)
if vim.bo[args.buf].buftype ~= '' then if vim.bo[args.buf].buftype ~= '' then return end
return
end
local file_path = vim.api.nvim_buf_get_name(args.buf) local file_path = vim.api.nvim_buf_get_name(args.buf)
if file_path == '' or file_path:match '^%w+://' then if file_path == '' or file_path:match '^%w+://' then return end
return
end
local uv = vim.uv or vim.loop local uv = vim.uv or vim.loop
local abs_path = vim.fn.fnamemodify(file_path, ':p') local abs_path = vim.fn.fnamemodify(file_path, ':p')
if not is_in_allowed_root(abs_path) then if not is_in_allowed_root(abs_path) then return end
return
end
local parent = vim.fn.fnamemodify(abs_path, ':h') local parent = vim.fn.fnamemodify(abs_path, ':h')
if uv.fs_stat(parent) == nil then if uv.fs_stat(parent) == nil then vim.fn.mkdir(parent, 'p', '0700') end
vim.fn.mkdir(parent, 'p', '0700')
end
ensure_owner_rwx(parent) ensure_owner_rwx(parent)
end, end,
}) })
@ -366,61 +284,19 @@ local treesitter_parsers = {
} }
-- [[ Configure and install plugins ]] -- [[ 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({ 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 = {} }, { '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', 'folke/which-key.nvim',
event = 'VimEnter', event = 'VimEnter',
---@module 'which-key' ---@module 'which-key'
---@type wk.Opts ---@type wk.Opts
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
opts = { opts = {
-- delay between pressing a key and opening which-key (milliseconds)
delay = 0, delay = 0,
icons = { mappings = vim.g.have_nerd_font }, icons = { mappings = vim.g.have_nerd_font },
-- Document existing key chains
spec = { spec = {
{ '<leader>a', group = 'Harpoon [A]dd' }, { '<leader>a', group = 'Harpoon [A]dd' },
{ '<leader>c', group = '[C]Make' }, { '<leader>c', group = '[C]Make' },
@ -435,92 +311,36 @@ require('lazy').setup({
{ '<leader>w', group = '[W]indow' }, { '<leader>w', group = '[W]indow' },
{ '<leader>x', group = 'Trouble' }, { '<leader>x', group = 'Trouble' },
{ '<leader>j', group = '[J]ump' }, { '<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' } }, { '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) { -- Fuzzy Finder (files, lsp, etc)
'nvim-telescope/telescope.nvim', '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,
-- its best to remove the Telescope plugin config entirely
-- instead of just disabling it here, to keep your config clean.
enabled = true, enabled = true,
event = 'VimEnter', event = 'VimEnter',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
{ -- If encountering errors, see telescope-fzf-native README for installation instructions {
'nvim-telescope/telescope-fzf-native.nvim', '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', 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, cond = function() return vim.fn.executable 'make' == 1 end,
}, },
{ 'nvim-telescope/telescope-ui-select.nvim' }, { '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 }, { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
}, },
config = function() 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 { 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 = { extensions = {
['ui-select'] = { require('telescope.themes').get_dropdown() }, ['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, 'fzf')
pcall(require('telescope').load_extension, 'ui-select') pcall(require('telescope').load_extension, 'ui-select')
-- See `:help telescope.builtin`
local builtin = require '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>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) 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>sc', builtin.commands, { desc = '[S]earch [C]ommands' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' }) 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, vim.keymap.set(
-- it is better explained there). This allows easily switching between pickers if you prefer using something else! 'n',
vim.api.nvim_create_autocmd('LspAttach', { '<leader>/',
group = vim.api.nvim_create_augroup('telescope-lsp-attach', { clear = true }), function()
callback = function(event) builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
local buf = event.buf winblend = 10,
previewer = false,
-- 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' })
end, 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( vim.keymap.set(
'n', 'n',
'<leader>s/', '<leader>s/',
@ -591,19 +378,13 @@ require('lazy').setup({
{ desc = '[S]earch [/] in Open Files' } { 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' }) vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
end, end,
}, },
-- LSP Plugins
{ {
-- Main LSP Configuration
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { 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', 'mason-org/mason.nvim',
---@module 'mason.settings' ---@module 'mason.settings'
@ -611,117 +392,37 @@ require('lazy').setup({
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
opts = {}, opts = {},
}, },
-- Maps LSP server names between nvim-lspconfig and Mason package names.
'mason-org/mason-lspconfig.nvim', 'mason-org/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP.
{ 'j-hui/fidget.nvim', opts = {} }, { 'j-hui/fidget.nvim', opts = {} },
}, },
config = function() 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', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-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
-- 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) local map = function(keys, func, desc, mode)
mode = mode or 'n' mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end end
-- Rename the variable under your cursor. local builtin = require 'telescope.builtin'
-- Most Language Servers support renaming across files, etc. local client = vim.lsp.get_client_by_id(event.data.client_id)
map('grn', vim.lsp.buf.rename, '[R]e[n]ame') 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' }) map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
map('grr', builtin.lsp_references, '[G]oto [R]eferences')
-- Find references for the word under your cursor. map('<leader>gr', builtin.lsp_references, '[G]oto [R]eferences')
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') map('gri', builtin.lsp_implementations, '[G]oto [I]mplementation')
map('<leader>gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') map('<leader>gi', builtin.lsp_implementations, '[G]oto [I]mplementation')
map('grd', builtin.lsp_definitions, '[G]oto [D]efinition')
-- Jump to the implementation of the word under your cursor. map('<leader>gd', builtin.lsp_definitions, '[G]oto [D]efinition')
-- 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('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
map('<leader>gD', 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 if client and client:supports_method('textDocument/documentHighlight', event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
@ -745,55 +446,18 @@ require('lazy').setup({
}) })
end 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 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') 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 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, 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_language_server_path = vim.fn.stdpath 'data' .. '/mason/packages/vue-language-server/node_modules/@vue/language-server'
local vue_typescript_plugin = { local vue_typescript_plugin = {
name = '@vue/typescript-plugin', name = '@vue/typescript-plugin',
@ -844,20 +508,14 @@ require('lazy').setup({
elixirls = {}, elixirls = {},
gh_actions_ls = {}, gh_actions_ls = {},
lua_ls = { lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = { settings = {
Lua = { Lua = {
completion = { completion = {
callSnippet = 'Replace', callSnippet = 'Replace',
}, },
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
}, },
}, },
}, },
-- Tools
eslint = {}, eslint = {},
astro = {}, astro = {},
vue_ls = {}, vue_ls = {},
@ -875,14 +533,6 @@ require('lazy').setup({
postgres_lsp = {}, postgres_lsp = {},
neocmake = {}, neocmake = {},
buf_ls = {}, 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 if has_go then
@ -900,9 +550,7 @@ require('lazy').setup({
} }
end end
if vim.fn.executable 'jq-lsp' == 1 then if vim.fn.executable 'jq-lsp' == 1 then servers.jqls = {} end
servers.jqls = {}
end
servers.marksman.filetypes = { 'markdown', 'mdx' } servers.marksman.filetypes = { 'markdown', 'mdx' }
servers.tailwindcss.filetypes = { servers.tailwindcss.filetypes = {
@ -928,19 +576,10 @@ require('lazy').setup({
automatic_enable = vim.tbl_keys(servers or {}), automatic_enable = vim.tbl_keys(servers or {}),
} }
-- Ensure the servers and tools above are installed local ensure_installed = vim.tbl_filter(function(server_name) return server_name ~= 'gopls' and server_name ~= 'jqls' end, vim.tbl_keys(servers or {}))
--
-- 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 {}))
vim.list_extend(ensure_installed, { vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code 'stylua',
'markdownlint', -- Used by nvim-lint for Markdown buffers 'markdownlint',
'prettierd', 'prettierd',
'prettier', 'prettier',
'clang-format', 'clang-format',
@ -952,14 +591,9 @@ require('lazy').setup({
require('mason-tool-installer').setup { ensure_installed = ensure_installed } 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 for server_name, config in pairs(servers) do
vim.lsp.config(server_name, config) vim.lsp.config(server_name, config)
end 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, end,
}, },
@ -980,9 +614,6 @@ require('lazy').setup({
opts = { opts = {
notify_on_error = false, notify_on_error = false,
format_on_save = function(bufnr) 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 } local disable_filetypes = { c = true, cpp = true }
if disable_filetypes[vim.bo[bufnr].filetype] then if disable_filetypes[vim.bo[bufnr].filetype] then
return nil return nil
@ -1004,11 +635,6 @@ require('lazy').setup({
yaml = { 'prettierd', 'prettier', stop_after_first = true }, yaml = { 'prettierd', 'prettier', stop_after_first = true },
c = { 'clang_format' }, c = { 'clang_format' },
cpp = { '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', event = 'VimEnter',
version = '1.*', version = '1.*',
dependencies = { dependencies = {
-- Snippet Engine
{ {
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
version = '2.*', version = '2.*',
build = (function() 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 if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end
return 'make install_jsregexp' return 'make install_jsregexp'
end)(), 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 = {}, opts = {},
}, },
}, },
@ -1047,42 +658,14 @@ require('lazy').setup({
---@type blink.cmp.Config ---@type blink.cmp.Config
opts = { opts = {
keymap = { 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', 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 = { appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = 'mono', nerd_font_variant = 'mono',
}, },
completion = { 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 }, documentation = { auto_show = false, auto_show_delay_ms = 500 },
}, },
@ -1092,27 +675,15 @@ require('lazy').setup({
snippets = { preset = 'luasnip' }, 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' }, fuzzy = { implementation = 'lua' },
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true }, 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', 'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins. priority = 1000,
config = function() config = function()
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
require('tokyonight').setup { 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' vim.cmd.colorscheme 'tokyonight-night'
end, end,
}, },
@ -1142,43 +710,18 @@ require('lazy').setup({
{ -- Collection of various small independent plugins/modules { -- Collection of various small independent plugins/modules
'nvim-mini/mini.nvim', 'nvim-mini/mini.nvim',
config = function() 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 } 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() require('mini.surround').setup()
-- Delete buffers while preserving window layout.
local bufremove = require 'mini.bufremove' local bufremove = require 'mini.bufremove'
bufremove.setup() bufremove.setup()
vim.keymap.set('n', '<leader>bd', function() vim.keymap.set('n', '<leader>bd', function() bufremove.delete(0, false) end, { desc = '[B]uffer [D]elete' })
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' 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 } 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 ---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function() return '%2l:%-2v' end statusline.section_location = function() return '%2l:%-2v' end
-- ... and there is more!
-- Check out: https://github.com/nvim-mini/mini.nvim
end, end,
}, },
@ -1193,11 +736,8 @@ require('lazy').setup({
end end
local ok, treesitter = pcall(require, 'nvim-treesitter') local ok, treesitter = pcall(require, 'nvim-treesitter')
if ok then if ok then treesitter.install(treesitter_parsers, { summary = true }):wait(300000) end
treesitter.install(treesitter_parsers, { summary = true }):wait(300000)
end
end, end,
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
config = function() config = function()
local treesitter = require 'nvim-treesitter' local treesitter = require 'nvim-treesitter'
treesitter.setup() treesitter.setup()
@ -1213,33 +753,12 @@ require('lazy').setup({
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('kickstart-treesitter', { clear = true }), group = vim.api.nvim_create_augroup('kickstart-treesitter', { clear = true }),
callback = function() callback = function() pcall(vim.treesitter.start) end,
pcall(vim.treesitter.start)
end,
}) })
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' }, { 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 }, { ---@diagnostic disable-line: missing-fields
rocks = { enabled = false }, rocks = { enabled = false },
ui = { ui = {

View File

@ -1,7 +1,9 @@
return { return {
'akinsho/bufferline.nvim', 'akinsho/bufferline.nvim',
event = 'VeryLazy', event = 'VeryLazy',
dependencies = { 'nvim-tree/nvim-web-devicons' }, dependencies = {
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
},
keys = { keys = {
{ '<S-h>', '<cmd>BufferLineCyclePrev<CR>', desc = 'Previous buffer' }, { '<S-h>', '<cmd>BufferLineCyclePrev<CR>', desc = 'Previous buffer' },
{ '<S-l>', '<cmd>BufferLineCycleNext<CR>', desc = 'Next buffer' }, { '<S-l>', '<cmd>BufferLineCycleNext<CR>', desc = 'Next buffer' },
@ -12,9 +14,7 @@ return {
local bufremove = require 'mini.bufremove' local bufremove = require 'mini.bufremove'
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].buflisted and vim.bo[bufnr].filetype ~= 'neo-tree' then if vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].buflisted and vim.bo[bufnr].filetype ~= 'neo-tree' then bufremove.delete(bufnr, false) end
bufremove.delete(bufnr, false)
end
end end
end, end,
desc = '[B]uffer [D]elete all', desc = '[B]uffer [D]elete all',

View File

@ -1,16 +1,6 @@
-- debug.lua
--
-- Shows how to use the DAP plugin to debug your code.
--
-- Primarily focused on configuring the debugger for Go, but can
-- be extended to other languages as well. That's why it's called
-- kickstart.nvim and not kitchen-sink.nvim ;)
local function has_configuration(configurations, name, adapter) local function has_configuration(configurations, name, adapter)
for _, configuration in ipairs(configurations or {}) do for _, configuration in ipairs(configurations or {}) do
if configuration.name == name and configuration.type == adapter then if configuration.name == name and configuration.type == adapter then return true end
return true
end
end end
return false return false
@ -27,9 +17,7 @@ local function setup_cpp_dap(dap)
name = launch_name, name = launch_name,
type = 'codelldb', type = 'codelldb',
request = 'launch', request = 'launch',
program = function() program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end,
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}', cwd = '${workspaceFolder}',
stopOnEntry = false, stopOnEntry = false,
args = {}, args = {},
@ -47,25 +35,15 @@ end
---@module 'lazy' ---@module 'lazy'
---@type LazySpec ---@type LazySpec
return { return {
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap', 'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = { dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui', 'rcarriga/nvim-dap-ui',
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio', 'nvim-neotest/nvim-nio',
-- Installs the debug adapters for you
'mason-org/mason.nvim', 'mason-org/mason.nvim',
'jay-babu/mason-nvim-dap.nvim', 'jay-babu/mason-nvim-dap.nvim',
-- Add your own debuggers here
'leoluz/nvim-dap-go', 'leoluz/nvim-dap-go',
}, },
keys = { keys = {
-- Basic debugging keymaps, feel free to change to your liking!
{ '<F5>', function() require('dap').continue() end, desc = 'Debug: Start/Continue' }, { '<F5>', function() require('dap').continue() end, desc = 'Debug: Start/Continue' },
{ '<F1>', function() require('dap').step_into() end, desc = 'Debug: Step Into' }, { '<F1>', function() require('dap').step_into() end, desc = 'Debug: Step Into' },
{ '<F2>', function() require('dap').step_over() end, desc = 'Debug: Step Over' }, { '<F2>', function() require('dap').step_over() end, desc = 'Debug: Step Over' },
@ -81,26 +59,13 @@ return {
local has_delve = vim.fn.executable 'dlv' == 1 local has_delve = vim.fn.executable 'dlv' == 1
require('mason-nvim-dap').setup { require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true, automatic_installation = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {}, handlers = {},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = { 'codelldb' }, ensure_installed = { 'codelldb' },
} }
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
dapui.setup { dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' }, icons = { expanded = '', collapsed = '', current_frame = '*' },
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
controls = { controls = {
@ -118,31 +83,15 @@ return {
}, },
} }
-- Change breakpoint icons
-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
-- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
-- local breakpoint_icons = vim.g.have_nerd_font
-- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
-- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' }
-- for type, icon in pairs(breakpoint_icons) do
-- local tp = 'Dap' .. type
-- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
-- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
-- end
dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close
if has_delve then if has_delve then require('dap-go').setup {
require('dap-go').setup { delve = {
delve = { detached = vim.fn.has 'win32' == 0,
-- On Windows delve must be run attached or it crashes. },
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring } end
detached = vim.fn.has 'win32' == 0,
},
}
end
setup_cpp_dap(dap) setup_cpp_dap(dap)
end, end,

View File

@ -1,6 +1,4 @@
-- Adds git related signs to the gutter, as well as utilities for managing changes -- Adds git related signs to the gutter, as well as utilities for managing changes
-- NOTE: gitsigns is already included in init.lua but contains only the base
-- config. This will add also the recommended keymaps.
---@module 'lazy' ---@module 'lazy'
---@type LazySpec ---@type LazySpec

View File

@ -1,8 +1,3 @@
-- You can add your own plugins here or in other files in this directory!
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
---@module 'lazy' ---@module 'lazy'
---@type LazySpec ---@type LazySpec
return {} return {}

View File

@ -21,44 +21,10 @@ return {
}, },
}) })
-- To allow other plugins to add linters to require('lint').linters_by_ft,
-- instead set linters_by_ft like this:
-- lint.linters_by_ft = lint.linters_by_ft or {}
-- lint.linters_by_ft['markdown'] = { 'markdownlint' }
--
-- However, note that this will enable a set of default linters,
-- which will cause errors unless these tools are available:
-- {
-- clojure = { "clj-kondo" },
-- dockerfile = { "hadolint" },
-- inko = { "inko" },
-- janet = { "janet" },
-- json = { "jsonlint" },
-- markdown = { "vale" },
-- rst = { "vale" },
-- ruby = { "ruby" },
-- terraform = { "tflint" },
-- text = { "vale" }
-- }
--
-- You can disable the default linters by setting their filetypes to nil:
-- lint.linters_by_ft['clojure'] = nil
-- lint.linters_by_ft['dockerfile'] = nil
-- lint.linters_by_ft['inko'] = nil
-- lint.linters_by_ft['janet'] = nil
-- lint.linters_by_ft['json'] = nil
-- lint.linters_by_ft['markdown'] = nil
-- lint.linters_by_ft['rst'] = nil
-- lint.linters_by_ft['ruby'] = nil
-- lint.linters_by_ft['terraform'] = nil
-- lint.linters_by_ft['text'] = nil
local function executable_cmd(cmd) local function executable_cmd(cmd)
if type(cmd) == 'function' then if type(cmd) == 'function' then
local ok, value = pcall(cmd) local ok, value = pcall(cmd)
if not ok then if not ok then return nil end
return nil
end
return value return value
end end
return cmd return cmd
@ -70,9 +36,7 @@ return {
for _, linter_name in ipairs(configured) do for _, linter_name in ipairs(configured) do
local linter = lint.linters[linter_name] local linter = lint.linters[linter_name]
local cmd = linter and executable_cmd(linter.cmd) local cmd = linter and executable_cmd(linter.cmd)
if cmd == nil or cmd == '' or vim.fn.executable(cmd) == 1 then if cmd == nil or cmd == '' or vim.fn.executable(cmd) == 1 then table.insert(available, linter_name) end
table.insert(available, linter_name)
end
end end
return available return available
end end
@ -80,9 +44,7 @@ return {
local function trigger_lint() local function trigger_lint()
if vim.bo.modifiable then if vim.bo.modifiable then
local linters = available_linters_for(vim.bo.filetype) local linters = available_linters_for(vim.bo.filetype)
if #linters > 0 then if #linters > 0 then lint.try_lint(linters) end
lint.try_lint(linters)
end
end end
end end
@ -116,9 +78,7 @@ return {
-- avoid superfluous noise, notably within the handy LSP pop-ups that -- avoid superfluous noise, notably within the handy LSP pop-ups that
-- describe the hovered symbol using Markdown. -- describe the hovered symbol using Markdown.
callback = function() callback = function()
if lint_enabled then if lint_enabled then trigger_lint() end
trigger_lint()
end
end, end,
}) })
end, end,

View File

@ -2,7 +2,10 @@ return {
{ {
'MeanderingProgrammer/render-markdown.nvim', 'MeanderingProgrammer/render-markdown.nvim',
ft = { 'markdown' }, ft = { 'markdown' },
dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, dependencies = {
'nvim-treesitter/nvim-treesitter',
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
},
opts = { opts = {
file_types = { 'markdown' }, file_types = { 'markdown' },
}, },
@ -11,24 +14,22 @@ return {
'iamcco/markdown-preview.nvim', 'iamcco/markdown-preview.nvim',
ft = { 'markdown' }, ft = { 'markdown' },
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
build = function() build = function() vim.fn['mkdp#util#install']() end,
vim.fn['mkdp#util#install']()
end,
init = function() init = function()
local browser = '' local browser = ''
local is_macos = vim.fn.has('macunix') == 1 local is_macos = vim.fn.has 'macunix' == 1
if is_macos then if is_macos then
vim.cmd([[ vim.cmd [[
function! OpenMarkdownPreview(url) abort function! OpenMarkdownPreview(url) abort
execute 'silent !open ' . shellescape(a:url) execute 'silent !open ' . shellescape(a:url)
endfunction endfunction
]]) ]]
elseif vim.fn.executable('google-chrome-stable') == 1 then elseif vim.fn.executable 'google-chrome-stable' == 1 then
browser = 'google-chrome-stable' browser = 'google-chrome-stable'
elseif vim.fn.executable('google-chrome') == 1 then elseif vim.fn.executable 'google-chrome' == 1 then
browser = 'google-chrome' browser = 'google-chrome'
elseif vim.fn.executable('chromium') == 1 then elseif vim.fn.executable 'chromium' == 1 then
browser = 'chromium' browser = 'chromium'
end end

View File

@ -8,7 +8,7 @@ return {
version = '*', version = '*',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
'MunifTanjim/nui.nvim', 'MunifTanjim/nui.nvim',
}, },
lazy = false, lazy = false,

View File

@ -2,14 +2,9 @@ return {
'NeogitOrg/neogit', 'NeogitOrg/neogit',
lazy = true, lazy = true,
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', -- required 'nvim-lua/plenary.nvim',
'sindrets/diffview.nvim', -- optional - Diff integration 'sindrets/diffview.nvim',
'nvim-telescope/telescope.nvim',
-- Only one of these is needed.
'nvim-telescope/telescope.nvim', -- optional
'ibhagwan/fzf-lua', -- optional
'nvim-mini/mini.pick', -- optional
'folke/snacks.nvim', -- optional
}, },
cmd = 'Neogit', cmd = 'Neogit',
keys = { keys = {