From 1bc4bfc2fe0c3fcd00584eb8bfad41c0a3ff8081 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 21 Feb 2024 00:17:30 -0500 Subject: [PATCH 01/22] wip: start exploring some new ideas --- init.lua | 838 +++++++++++++-------------- lazy-lock.json | 29 + lua/kickstart/plugins/autoformat.lua | 74 --- 3 files changed, 444 insertions(+), 497 deletions(-) create mode 100644 lazy-lock.json delete mode 100644 lua/kickstart/plugins/autoformat.lua diff --git a/init.lua b/init.lua index fd4567d9..52edd0ed 100644 --- a/init.lua +++ b/init.lua @@ -21,11 +21,15 @@ Kickstart.nvim is a template for your own configuration. And then you can explore or search through `:help lua-guide` - https://neovim.io/doc/user/lua-guide.html +Kickstart Installation: + Kickstart Guide: I have left several `:help X` comments throughout the init.lua You should run that command and read that help section for more information. +- TODO: Should write a little bit more about how to use help. And also really push them to be reading the help. + Could probably add a few more links now as well. Particularly for lazy.nvim keys, which I didn't do. In addition, I have some `NOTE:` items throughout the file. These are for you, the reader to help understand what is happening. Feel free to delete @@ -36,6 +40,9 @@ I hope you enjoy your Neovim journey, - TJ P.S. You can delete this when you're done too. It's your config now :) + +TODO: Include PDE video link? ;) +TODO: Include Neovim "Listening To Friendly Manual"? ;) --]] -- Set as the leader key @@ -60,6 +67,78 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +-- [[ Setting options ]] +-- See `:help vim.o` +-- NOTE: You can change these options as you wish! + +-- Set highlight on search +vim.o.hlsearch = false + +-- Make line numbers default +vim.wo.number = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.o.clipboard = 'unnamedplus' + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- NOTE: You should make sure your terminal supports this +vim.o.termguicolors = true + +-- [[ Basic Keymaps ]] + +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- 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 , which +-- is not what someone will guess without a bit more experience. +vim.keymap.set('t', '', '', { desc = 'Escape Escape exits terminal mode' }) + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + group = highlight_group, + callback = function() + vim.highlight.on_yank() + end, +}) + -- [[ Configure plugins ]] -- NOTE: Here is where you install your plugins. -- You can configure plugins using the `config` key. @@ -78,25 +157,132 @@ require('lazy').setup({ -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. - { - -- LSP Configuration & Plugins + + { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', + { 'williamboman/mason.nvim', opts = {} }, + { 'williamboman/mason-lspconfig.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + { 'folke/neodev.nvim', opts = {} }, -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, + }, + config = function() + -- 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. They will be passed to + -- the `settings` field of the server config. You must look up that documentation yourself. + -- + -- If you want to override the default filetypes that your language server will attach to you can + -- define the property 'filetypes' to the map in question. + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, - -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + } + + -- This function gets run when an LSP connects to a particular buffer. + local on_attach = function(_, bufnr) + -- 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 + -- many times. + -- + -- 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 nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + -- Important LSP Navigation keybinds + nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- Important LSP Action keybinds + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', function() + vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } + end, '[C]ode [A]ction') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- LSP Workspace Management + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + end + + -- Ensure the servers above are installed + local mason_lspconfig = require 'mason-lspconfig' + mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), + } + + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) + mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + } + end, + } + end, + }, + + { -- Autoformat + 'stevearc/conform.nvim', + opts = { + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + formatters_by_ft = { + lua = { 'stylua' }, + -- Conform will run multiple formatters sequentially + -- python = { "isort", "black" }, + -- Use a sub-list to run only the first available formatter + -- javascript = { { "prettierd", "prettier" } }, + }, }, }, - { - -- Autocompletion + { -- Autocompletion 'hrsh7th/nvim-cmp', dependencies = { -- Snippet Engine & its associated nvim-cmp source @@ -121,12 +307,87 @@ require('lazy').setup({ -- Adds a number of user-friendly snippets 'rafamadriz/friendly-snippets', }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + require('luasnip.loaders.from_vscode').lazy_load() + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, + } + end, }, - -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { - -- Adds git related signs to the gutter, as well as utilities for managing changes + { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VeryLazy', + config = function() + require('which-key').setup() + + -- document existing key chains + require('which-key').register { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, + ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + } + -- register which-key VISUAL mode + -- required for visual hs (hunk stage) to work + require('which-key').register({ + [''] = { name = 'VISUAL ' }, + ['h'] = { 'Git [H]unk' }, + }, { mode = 'v' }) + end, + }, + + { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- See `:help gitsigns.txt` @@ -201,19 +462,29 @@ require('lazy').setup({ }, { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - lazy = false, + 'folke/tokyonight.nvim', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins config = function() - require('onedark').setup { - -- Set a style preset. 'dark' is default. - style = 'dark', -- dark, darker, cool, deep, warm, warmer, light - } - require('onedark').load() + -- load the colorscheme here + vim.cmd.colorscheme 'tokyonight' end, }, + -- { + -- -- Theme inspired by Atom + -- 'navarasu/onedark.nvim', + -- priority = 1000, + -- lazy = false, + -- config = function() + -- require('onedark').setup { + -- -- Set a style preset. 'dark' is default. + -- style = 'dark', -- dark, darker, cool, deep, warm, warmer, light + -- } + -- require('onedark').load() + -- end, + -- }, + { -- Set lualine as statusline 'nvim-lualine/lualine.nvim', @@ -228,8 +499,7 @@ require('lazy').setup({ }, }, - { - -- Add indentation guides even on blank lines + { -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help ibl` @@ -240,8 +510,7 @@ require('lazy').setup({ -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, - -- Fuzzy Finder (files, lsp, etc) - { + { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { @@ -259,21 +528,139 @@ require('lazy').setup({ end, }, }, + config = function() + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + } + + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- Also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular pickers + vim.keymap.set('n', 's/', function() + require('telescope.builtin').live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + end, }, - { - -- Highlight, edit, and navigate code + { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', }, build = ':TSUpdate', + config = function() + -- [[ Configure Treesitter ]] + -- See `:help nvim-treesitter` + -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, + -- Install languages synchronously (only applied to `ensure_installed`) + sync_install = false, + -- List of parsers to ignore installing + ignore_install = {}, + -- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- }, + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } + end, }, -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', -- require 'kickstart.plugins.debug', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -285,400 +672,5 @@ require('lazy').setup({ -- { import = 'custom.plugins' }, }, {}) --- [[ Setting options ]] --- See `:help vim.o` --- NOTE: You can change these options as you wish! - --- Set highlight on search -vim.o.hlsearch = false - --- Make line numbers default -vim.wo.number = true - --- Enable mouse mode -vim.o.mouse = 'a' - --- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.o.clipboard = 'unnamedplus' - --- Enable break indent -vim.o.breakindent = true - --- Save undo history -vim.o.undofile = true - --- Case-insensitive searching UNLESS \C or capital in search -vim.o.ignorecase = true -vim.o.smartcase = true - --- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 300 - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - --- NOTE: You should make sure your terminal supports this -vim.o.termguicolors = true - --- [[ Basic Keymaps ]] - --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { - callback = function() - vim.highlight.on_yank() - end, - group = highlight_group, - pattern = '*', -}) - --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- Telescope live_grep in git root --- Function to find the git root directory based on the current buffer's path -local function find_git_root() - -- Use the current buffer's path as the starting point for the git search - local current_file = vim.api.nvim_buf_get_name(0) - local current_dir - local cwd = vim.fn.getcwd() - -- If the buffer is not associated with a file, return nil - if current_file == '' then - current_dir = cwd - else - -- Extract the directory from the current file's path - current_dir = vim.fn.fnamemodify(current_file, ':h') - end - - -- Find the Git root directory from the current file's path - local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] - if vim.v.shell_error ~= 0 then - print 'Not a git repository. Searching on current working directory' - return cwd - end - return git_root -end - --- Custom live_grep function to search in git root -local function live_grep_git_root() - local git_root = find_git_root() - if git_root then - require('telescope.builtin').live_grep { - search_dirs = { git_root }, - } - end -end - -vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -local function telescope_live_grep_open_files() - require('telescope.builtin').live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } -end -vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) -vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` --- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' -vim.defer_fn(function() - require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - -- Install languages synchronously (only applied to `ensure_installed`) - sync_install = false, - -- List of parsers to ignore installing - ignore_install = {}, - -- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- }, - modules = {}, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, - } -end, 0) - --- [[ Configure LSP ]] --- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) - -- 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 - -- many times. - -- - -- 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 nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end - - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', function() - vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } - end, '[C]ode [A]ction') - - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) -end - --- document existing key chains -require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, -} --- register which-key VISUAL mode --- required for visual hs (hunk stage) to work -require('which-key').register({ - [''] = { name = 'VISUAL ' }, - ['h'] = { 'Git [H]unk' }, -}, { mode = 'v' }) - --- mason-lspconfig requires that these setup functions are called in this order --- before setting up the servers. -require('mason').setup() -require('mason-lspconfig').setup() - --- 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. They will be passed to --- the `settings` field of the server config. You must look up that documentation yourself. --- --- If you want to override the default filetypes that your language server will attach to you can --- define the property 'filetypes' to the map in question. -local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, - - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, -} - --- Setup neovim lua configuration -require('neodev').setup() - --- nvim-cmp supports additional completion capabilities, so broadcast that to servers -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - --- Ensure the servers above are installed -local mason_lspconfig = require 'mason-lspconfig' - -mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), -} - -mason_lspconfig.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, - } - end, -} - --- [[ Configure nvim-cmp ]] --- See `:help cmp` -local cmp = require 'cmp' -local luasnip = require 'luasnip' -require('luasnip.loaders.from_vscode').lazy_load() -luasnip.config.setup {} - -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { - completeopt = 'menu,menuone,noinsert', - }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, -} - -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..79a76e7d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,29 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "4c01323a67f1636d73803aad4e8e735bad7a9561" }, + "fidget.nvim": { "branch": "main", "commit": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa" }, + "friendly-snippets": { "branch": "main", "commit": "dbd45e9ba76d535e4cba88afa1b7aa43bb765336" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "60f6805b12a12e8a912aeb2f975dec1794a8994e" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "neodev.nvim": { "branch": "main", "commit": "bbe17de89345ce40725e721d347c596dc4a02b32" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lspconfig": { "branch": "master", "commit": "1699ce10c3aaf861cfa0c1303fcd19d2ed93e7ad" }, + "nvim-treesitter": { "branch": "master", "commit": "6bd108a6f10aa01b854c3c673b6d9d61662a8c93" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" }, + "vim-fugitive": { "branch": "master", "commit": "011cf4fcb93a9649ffc6dcdff56ef948f5d0f7cc" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/kickstart/plugins/autoformat.lua deleted file mode 100644 index bc56b15b..00000000 --- a/lua/kickstart/plugins/autoformat.lua +++ /dev/null @@ -1,74 +0,0 @@ --- autoformat.lua --- --- Use your language server to automatically format your code on save. --- Adds additional commands as well to manage the behavior - -return { - 'neovim/nvim-lspconfig', - config = function() - -- Switch for controlling whether you want autoformatting. - -- Use :KickstartFormatToggle to toggle autoformatting on or off - local format_is_enabled = true - vim.api.nvim_create_user_command('KickstartFormatToggle', function() - format_is_enabled = not format_is_enabled - print('Setting autoformatting to: ' .. tostring(format_is_enabled)) - end, {}) - - -- Create an augroup that is used for managing our formatting autocmds. - -- We need one augroup per client to make sure that multiple clients - -- can attach to the same buffer without interfering with each other. - local _augroups = {} - local get_augroup = function(client) - if not _augroups[client.id] then - local group_name = 'kickstart-lsp-format-' .. client.name - local id = vim.api.nvim_create_augroup(group_name, { clear = true }) - _augroups[client.id] = id - end - - return _augroups[client.id] - end - - -- Whenever an LSP attaches to a buffer, we will run this function. - -- - -- See `:help LspAttach` for more information about this autocmd event. - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), - -- This is where we attach the autoformatting for reasonable clients - callback = function(args) - local client_id = args.data.client_id - local client = vim.lsp.get_client_by_id(client_id) - local bufnr = args.buf - - -- Only attach to clients that support document formatting - if not client.server_capabilities.documentFormattingProvider then - return - end - - -- Tsserver usually works poorly. Sorry you work with bad languages - -- You can remove this line if you know what you're doing :) - if client.name == 'tsserver' then - return - end - - -- Create an autocmd that will run *before* we save the buffer. - -- Run the formatting command for the LSP that has just attached. - vim.api.nvim_create_autocmd('BufWritePre', { - group = get_augroup(client), - buffer = bufnr, - callback = function() - if not format_is_enabled then - return - end - - vim.lsp.buf.format { - async = false, - filter = function(c) - return c.id == client.id - end, - } - end, - }) - end, - }) - end, -} From c0ccf101ad520e1ee726cec853b996d03ab9925f Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 21 Feb 2024 09:40:30 -0500 Subject: [PATCH 02/22] wip: starting from stream --- init.lua | 114 +++++++++++++------------------------------------------ 1 file changed, 27 insertions(+), 87 deletions(-) diff --git a/init.lua b/init.lua index 52edd0ed..5fc400d6 100644 --- a/init.lua +++ b/init.lua @@ -150,11 +150,13 @@ require('lazy').setup({ -- Git related plugins 'tpope/vim-fugitive', - 'tpope/vim-rhubarb', -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', + -- Surrounding motions, like "ysiw" (TODO: Write a description for this) + 'tpope/vim-surround', + -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. @@ -162,6 +164,7 @@ require('lazy').setup({ 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim + -- TODO: It seems that there is some confusion w/ the setup here, so i need to check it out some more { 'williamboman/mason.nvim', opts = {} }, { 'williamboman/mason-lspconfig.nvim', opts = {} }, @@ -244,23 +247,22 @@ require('lazy').setup({ end, '[W]orkspace [L]ist Folders') end - -- Ensure the servers above are installed - local mason_lspconfig = require 'mason-lspconfig' - mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), - } - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) - mason_lspconfig.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, - } - end, + + -- Ensure the servers above are installed + require('mason-lspconfig').setup { + ensure_installed = vim.tbl_keys(servers), + handlers = { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + } + end, + }, } end, }, @@ -398,66 +400,6 @@ require('lazy').setup({ topdelete = { text = '‾' }, changedelete = { text = '~' }, }, - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map({ 'n', 'v' }, ']c', function() - if vim.wo.diff then - return ']c' - end - vim.schedule(function() - gs.next_hunk() - end) - return '' - end, { expr = true, desc = 'Jump to next hunk' }) - - map({ 'n', 'v' }, '[c', function() - if vim.wo.diff then - return '[c' - end - vim.schedule(function() - gs.prev_hunk() - end) - return '' - end, { expr = true, desc = 'Jump to previous hunk' }) - - -- Actions - -- visual mode - map('v', 'hs', function() - gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) - map('v', 'hr', function() - gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) - -- normal mode - map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) - map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) - map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) - map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) - map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) - map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) - map('n', 'hb', function() - gs.blame_line { full = false } - end, { desc = 'git blame line' }) - map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) - map('n', 'hD', function() - gs.diffthis '~' - end, { desc = 'git diff against last commit' }) - - -- Toggles - map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) - map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) - - -- Text object - map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) - end, }, }, @@ -499,14 +441,6 @@ require('lazy').setup({ }, }, - { -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help ibl` - main = 'ibl', - opts = {}, - }, - -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, @@ -527,6 +461,8 @@ require('lazy').setup({ return vim.fn.executable 'make' == 1 end, }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + -- { 'nvim-tree/nvim-web-devicons' } -- Useful for getting pretty icons, but requires special font }, config = function() -- [[ Configure Telescope ]] @@ -540,10 +476,16 @@ require('lazy').setup({ }, }, }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, } -- Enable telescope fzf native, if installed pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') -- See `:help telescope.builtin` vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) @@ -590,14 +532,12 @@ require('lazy').setup({ ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, + ensure_installed = { 'c', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, -- Install languages synchronously (only applied to `ensure_installed`) sync_install = false, - -- List of parsers to ignore installing - ignore_install = {}, -- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- }, highlight = { enable = true }, indent = { enable = true }, From e419aa5ef6b80fc0cf3bd92d618030aba69beb8f Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 21 Feb 2024 12:10:21 -0500 Subject: [PATCH 03/22] wip: more work from twitch --- init.lua | 186 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 96 insertions(+), 90 deletions(-) diff --git a/init.lua b/init.lua index 5fc400d6..561c53ef 100644 --- a/init.lua +++ b/init.lua @@ -41,6 +41,8 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now :) +P.P.S. If you use nix, you can figure out how to install this yourself :) + TODO: Include PDE video link? ;) TODO: Include Neovim "Listening To Friendly Manual"? ;) --]] @@ -102,9 +104,6 @@ vim.wo.signcolumn = 'yes' vim.o.updatetime = 250 vim.o.timeoutlen = 300 --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true @@ -155,6 +154,8 @@ require('lazy').setup({ 'tpope/vim-sleuth', -- Surrounding motions, like "ysiw" (TODO: Write a description for this) + -- mini-ai + -- mini-surround 'tpope/vim-surround', -- NOTE: This is where your plugins related to LSP can be installed. @@ -164,43 +165,20 @@ require('lazy').setup({ 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim - -- TODO: It seems that there is some confusion w/ the setup here, so i need to check it out some more - { 'williamboman/mason.nvim', opts = {} }, - { 'williamboman/mason-lspconfig.nvim', opts = {} }, + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', -- Additional lua configuration, makes nvim stuff amazing! - { 'folke/neodev.nvim', opts = {} }, + 'folke/neodev.nvim', -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, }, config = function() - -- 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. They will be passed to - -- the `settings` field of the server config. You must look up that documentation yourself. - -- - -- If you want to override the default filetypes that your language server will attach to you can - -- define the property 'filetypes' to the map in question. - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, - - lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - } + -- First, enable neodev. This is helpful for auto-configuring the Lua LSP + -- to understand your Neovim environment + require('neodev').setup() -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) @@ -219,6 +197,9 @@ require('lazy').setup({ end -- Important LSP Navigation keybinds + -- + -- Jump to the definition of the word under your cursor. + -- To jump back, press . nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') @@ -226,40 +207,79 @@ require('lazy').setup({ nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- Important LSP Action keybinds + -- NOTE: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- Rename the variable under your cursor nmap('rn', 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. nmap('ca', function() vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } end, '[C]ode [A]ction') -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + + -- Show the signature of the function you're currently completing. nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- LSP Workspace Management - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') end - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP Specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilties with nvim cmp, and then broadcast that to the servers. local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) + -- 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): TODO + -- - 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 servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + + lua_ls = { + -- cmd = {...}, + -- filetypes { ...}, + -- capabilities = {}, + settings = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } + -- Ensure the servers above are installed + require('mason').setup() require('mason-lspconfig').setup { ensure_installed = vim.tbl_keys(servers), handlers = { function(server_name) + local server = servers[server_name] or {} require('lspconfig')[server_name].setup { - capabilities = capabilities, + cmd = server.cmd, + settings = server.settings, + filetypes = server.filetypes, on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, + -- TODO: Think about what we wanna do here. + -- capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities), + capabilities = server.capabilities or capabilities, } end, }, @@ -323,34 +343,37 @@ require('lazy').setup({ end, }, completion = { - completeopt = 'menu,menuone,noinsert', + completeopt = 'menu,menuone,noinsert,noselect', }, + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` mapping = cmp.mapping.preset.insert { + -- Select the [n]ext item [''] = cmp.mapping.select_next_item(), + -- Select the [p]revious item [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [''] = cmp.mapping.confirm { select = true }, + -- Manually trigger a completion from nvim-cmp [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then + -- Think of as moving to the right of your snippet expansion. + -- So if you have a snippet that's like: + -- function $name($args) + -- $body + -- end + -- + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() - else - fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then luasnip.jump(-1) - else - fallback() end end, { 'i', 's' }), }, @@ -380,12 +403,6 @@ require('lazy').setup({ ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, } - -- register which-key VISUAL mode - -- required for visual hs (hunk stage) to work - require('which-key').register({ - [''] = { name = 'VISUAL ' }, - ['h'] = { 'Git [H]unk' }, - }, { mode = 'v' }) end, }, @@ -403,7 +420,7 @@ require('lazy').setup({ }, }, - { + { -- You can easily change to a different colorscheme. 'folke/tokyonight.nvim', lazy = false, -- make sure we load this during startup if it is your main colorscheme priority = 1000, -- make sure to load this before all the other start plugins @@ -413,22 +430,7 @@ require('lazy').setup({ end, }, - -- { - -- -- Theme inspired by Atom - -- 'navarasu/onedark.nvim', - -- priority = 1000, - -- lazy = false, - -- config = function() - -- require('onedark').setup { - -- -- Set a style preset. 'dark' is default. - -- style = 'dark', -- dark, darker, cool, deep, warm, warmer, light - -- } - -- require('onedark').load() - -- end, - -- }, - - { - -- Set lualine as statusline + { -- Set lualine as statusline 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` opts = { @@ -462,7 +464,10 @@ require('lazy').setup({ end, }, { 'nvim-telescope/telescope-ui-select.nvim' }, - -- { 'nvim-tree/nvim-web-devicons' } -- Useful for getting pretty icons, but requires special font + -- Useful for getting pretty icons, but requires special font. + -- If you already have a Nerd Font, or terminal set up with fallback fonts + -- you can enable this + -- { 'nvim-tree/nvim-web-devicons' } }, config = function() -- [[ Configure Telescope ]] @@ -602,6 +607,7 @@ require('lazy').setup({ -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. -- require 'kickstart.plugins.debug', + -- require 'kickstart.plugins.indent_line', -- 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 From 2d9bfa0bb75c0137eee007c5423939fa74bba424 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 21 Feb 2024 14:10:45 -0500 Subject: [PATCH 04/22] wip: more work from twitch --- init.lua | 214 +++++++++++++++++++++++-------------------------------- 1 file changed, 88 insertions(+), 126 deletions(-) diff --git a/init.lua b/init.lua index 561c53ef..1ad34ee4 100644 --- a/init.lua +++ b/init.lua @@ -17,7 +17,6 @@ Kickstart.nvim is a template for your own configuration. a guide. One possible example: - https://learnxinyminutes.com/docs/lua/ - And then you can explore or search through `:help lua-guide` - https://neovim.io/doc/user/lua-guide.html @@ -26,10 +25,18 @@ Kickstart Installation: Kickstart Guide: +The first thing you should do, is run `: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. + + Additionally, we provide a keymap "sh" to [s]earch the [h]elp documentation, + 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 You should run that command and read that help section for more information. -- TODO: Should write a little bit more about how to use help. And also really push them to be reading the help. - Could probably add a few more links now as well. Particularly for lazy.nvim keys, which I didn't do. In addition, I have some `NOTE:` items throughout the file. These are for you, the reader to help understand what is happening. Feel free to delete @@ -41,8 +48,6 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now :) -P.P.S. If you use nix, you can figure out how to install this yourself :) - TODO: Include PDE video link? ;) TODO: Include Neovim "Listening To Friendly Manual"? ;) --]] @@ -53,22 +58,6 @@ TODO: Include Neovim "Listening To Friendly Manual"? ;) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' --- [[ Install `lazy.nvim` plugin manager ]] --- https://github.com/folke/lazy.nvim --- `:help lazy.nvim.txt` for more info -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then - vim.fn.system { - 'git', - 'clone', - '--filter=blob:none', - 'https://github.com/folke/lazy.nvim.git', - '--branch=stable', -- latest stable release - lazypath, - } -end -vim.opt.rtp:prepend(lazypath) - -- [[ Setting options ]] -- See `:help vim.o` -- NOTE: You can change these options as you wish! @@ -107,6 +96,10 @@ vim.o.timeoutlen = 300 -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true +-- Configure how new splits should be opened +vim.o.splitright = true +vim.o.splitbelow = true + -- [[ Basic Keymaps ]] -- Keymaps for better default experience @@ -138,6 +131,21 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- [[ Install `lazy.nvim` plugin manager ]] +-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + } +end +vim.opt.rtp:prepend(lazypath) + -- [[ Configure plugins ]] -- NOTE: Here is where you install your plugins. -- You can configure plugins using the `config` key. @@ -147,20 +155,9 @@ vim.api.nvim_create_autocmd('TextYankPost', { require('lazy').setup({ -- NOTE: First, some plugins that don't require any configuration - -- Git related plugins - 'tpope/vim-fugitive', - -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', - -- Surrounding motions, like "ysiw" (TODO: Write a description for this) - -- mini-ai - -- mini-surround - 'tpope/vim-surround', - - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. - { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { @@ -189,11 +186,7 @@ require('lazy').setup({ -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = 'LSP: ' .. desc }) end -- Important LSP Navigation keybinds @@ -430,19 +423,42 @@ require('lazy').setup({ end, }, - { -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = false, - theme = 'auto', - component_separators = '|', - section_separators = '', - }, - }, + { -- Collection of various small independent plugins/modules + 'echasnovski/mini.nvim', + config = function() + -- Better Around/Inside textobjects + -- + -- Examples: + -- - `af` - around function call + -- - `inq` - inside next quote + require('mini.ai').setup { n_lines = 500 } + + -- Add/delete/replace surroundings (brackets, quotes, etc.) + require('mini.surround').setup() + + -- Simple and easy statusline. + -- You could remove this setup call if you don't like it, + -- and try some other statusline plugin + require('mini.statusline').setup() + + -- ... and there is more! + -- Check out: https://github.com/echasnovski/mini.nvim + end, }, + -- { -- Set lualine as statusline + -- 'nvim-lualine/lualine.nvim', + -- -- See `:help lualine.txt` + -- opts = { + -- options = { + -- icons_enabled = false, + -- theme = 'auto', + -- component_separators = '|', + -- section_separators = '', + -- }, + -- }, + -- }, + -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, @@ -493,21 +509,23 @@ require('lazy').setup({ pcall(require('telescope').load_extension, 'ui-select') -- See `:help telescope.builtin` - vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) - vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) - vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) - vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) @@ -516,7 +534,7 @@ require('lazy').setup({ -- Also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular pickers vim.keymap.set('n', 's/', function() - require('telescope.builtin').live_grep { + builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } @@ -526,80 +544,24 @@ require('lazy').setup({ { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, build = ':TSUpdate', config = function() - -- [[ Configure Treesitter ]] - -- See `:help nvim-treesitter` - -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - -- Install languages synchronously (only applied to `ensure_installed`) - sync_install = false, - -- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- }, + auto_install = true, highlight = { enable = true }, indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, } + + -- 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 with nvim-treesitter, see :help nvim-treesitter-incremental-selection-mod + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects end, }, From e9f8139fcf32112cf0b8bd7b4b4d991572247034 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 21 Feb 2024 15:56:24 -0500 Subject: [PATCH 05/22] wip: more work from twitch --- init.lua | 353 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 219 insertions(+), 134 deletions(-) diff --git a/init.lua b/init.lua index 1ad34ee4..6f706be5 100644 --- a/init.lua +++ b/init.lua @@ -153,10 +153,190 @@ vim.opt.rtp:prepend(lazypath) -- You can also configure plugins after the setup call, -- as they will be available in your neovim runtime. require('lazy').setup({ - -- NOTE: First, some plugins that don't require any configuration + -- NOTE: Plugins can be added by simply giving a link or 'owner/repo' link. - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', + 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + + -- NOTE: Plugins can also be added by using a table, + -- with the first argument being the 'owner/repo' and then following + -- keys can be used to configure plugin behavior. + -- + -- For example, using: + -- opts = { ... } + -- + -- is the same as doing: + -- require("myplugin").setup { ... } + -- + -- Lazy will automatically load and run the setup for this plugin + + { -- Autoformat + 'stevearc/conform.nvim', + event = 'VeryLazy', + opts = { + 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" } }, + }, + }, + }, + + -- 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 = 'VeryLazy' + -- + -- which loads which-key after all the UI elements are loaded. + -- + -- Then, because we use the `config` key, the configuration only runs + -- after the plugin has been loaded: + -- config = function() ... end + + { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VeryLazy', + config = function() + require('which-key').setup() + + -- document existing key chains + require('which-key').register { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, + ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + } + end, + }, + + -- NOTE: Plugins can specify dependencies. + -- + -- The dependencies are proper plugin specifications as well - anything + -- you do for a plugin at the top level, you can do for a dependency. + -- + -- Use the `dependencies` key to specify the dependencies of a particular plugin + + { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + event = 'VeryLazy', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for install instructions + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: `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', + + -- NOTE: `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires special font. + -- If you already have a Nerd Font, or terminal set up with fallback fonts + -- you can enable this + -- { 'nvim-tree/nvim-web-devicons' } + }, + config = function() + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- 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: + -- - 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! + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- Also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular pickers + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + -- Shortcut for searching your neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.find_files { + cwd = vim.fn.stdpath 'config', + } + end, { desc = '[S]earch [N]eovim files' }) + end, + }, { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', @@ -164,6 +344,7 @@ require('lazy').setup({ -- Automatically install LSPs to stdpath for neovim 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', @@ -173,6 +354,31 @@ require('lazy').setup({ { 'j-hui/fidget.nvim', opts = {} }, }, config = function() + -- Brief Aside: **What is LSP?** + -- + -- LSP is an acronym 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 `mason-lspconfig` both 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 + -- First, enable neodev. This is helpful for auto-configuring the Lua LSP -- to understand your Neovim environment require('neodev').setup() @@ -260,8 +466,12 @@ require('lazy').setup({ -- Ensure the servers above are installed require('mason').setup() + + -- TODO: Think about lspconfig mason + local installed = { 'stylua' } + vim.list_extend(installed, vim.tbl_keys(servers)) + require('mason-tool-installer').setup { ensure_installed = installed } require('mason-lspconfig').setup { - ensure_installed = vim.tbl_keys(servers), handlers = { function(server_name) local server = servers[server_name] or {} @@ -280,25 +490,9 @@ require('lazy').setup({ end, }, - { -- Autoformat - 'stevearc/conform.nvim', - opts = { - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform will run multiple formatters sequentially - -- python = { "isort", "black" }, - -- Use a sub-list to run only the first available formatter - -- javascript = { { "prettierd", "prettier" } }, - }, - }, - }, - { -- Autocompletion 'hrsh7th/nvim-cmp', + event = 'InsertEnter', dependencies = { -- Snippet Engine & its associated nvim-cmp source { @@ -379,26 +573,6 @@ require('lazy').setup({ end, }, - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - event = 'VeryLazy', - config = function() - require('which-key').setup() - - -- document existing key chains - require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - } - end, - }, - { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { @@ -414,6 +588,10 @@ require('lazy').setup({ }, { -- 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', lazy = false, -- make sure we load this during startup if it is your main colorscheme priority = 1000, -- make sure to load this before all the other start plugins @@ -446,102 +624,9 @@ require('lazy').setup({ end, }, - -- { -- Set lualine as statusline - -- 'nvim-lualine/lualine.nvim', - -- -- See `:help lualine.txt` - -- opts = { - -- options = { - -- icons_enabled = false, - -- theme = 'auto', - -- component_separators = '|', - -- section_separators = '', - -- }, - -- }, - -- }, - -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, - { -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - -- Fuzzy Finder Algorithm which requires local dependencies to be built. - -- Only load if `make` is available. Make sure you have the system - -- requirements installed. - { - 'nvim-telescope/telescope-fzf-native.nvim', - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - -- Useful for getting pretty icons, but requires special font. - -- If you already have a Nerd Font, or terminal set up with fallback fonts - -- you can enable this - -- { 'nvim-tree/nvim-web-devicons' } - }, - config = function() - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable telescope fzf native, if installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- Also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular pickers - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - end, - }, - { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', From f1d3a3c32f86021584d057bf86221229c6241975 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 22 Feb 2024 13:14:05 -0500 Subject: [PATCH 06/22] this one is for KD --- init.lua | 215 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 119 insertions(+), 96 deletions(-) diff --git a/init.lua b/init.lua index 6f706be5..84c1f51a 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,21 @@ ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== +======== .-----. ======== +======== .----------------------. | === | ======== +======== |.-""""""""""""""""""-.| |-----| ======== +======== || || | === | ======== +======== || KICKSTART.NVIM || |-----| ======== +======== || || | === | ======== +======== || || |-----| ======== +======== ||:Tutor || |:::::| ======== +======== |'-..................-'| |____.| ======== +======== `"")----------------(""` ___________ ======== +======== /::::::::::| |::::::::::\ \ no mouse \ ======== +======== /:::========| |==hjkl==:::\ \ required \ ======== +======== '""""""""""""' '""""""""""""' '""""""""""' ======== +===================================================================== +===================================================================== Kickstart.nvim is *not* a distribution. @@ -20,36 +35,43 @@ Kickstart.nvim is a template for your own configuration. And then you can explore or search through `:help lua-guide` - https://neovim.io/doc/user/lua-guide.html -Kickstart Installation: - - Kickstart Guide: -The first thing you should do, is run `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. + The very first thing you should do, is run the command `:Tutor` inside Neovim. + If you don't know what this means, type the following: + - + - : + - Tutor + - - 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. + (If you already know how the Neovim basics, you can skip this step) - Additionally, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not sure exactly what you're looking for. + Once you've completed that, you can continue working through **AND READING** the rest + of the kickstart 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. + 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. -In addition, I have some `NOTE:` items 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 for when you -are first encountering a few different constructs in your nvim config. + 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 "sh" to [s]earch the [h]elp documentation, + 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 + You should run that command and read that help section for more information. + + NOTE: Look for lines like this + + 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 + for when you are first encountering a few different constructs in your nvim config. I hope you enjoy your Neovim journey, - TJ -P.S. You can delete this when you're done too. It's your config now :) - -TODO: Include PDE video link? ;) -TODO: Include Neovim "Listening To Friendly Manual"? ;) +P.S. You can delete this when you're done too. It's your config now! :) --]] -- Set as the leader key @@ -59,46 +81,50 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- [[ Setting options ]] --- See `:help vim.o` +-- See `:help vim.opt` -- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` -- Set highlight on search -vim.o.hlsearch = false +vim.opt.hlsearch = false -- Make line numbers default -vim.wo.number = true +vim.opt.number = true -- Enable mouse mode -vim.o.mouse = 'a' +vim.opt.mouse = 'a' -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.o.clipboard = 'unnamedplus' +vim.opt.clipboard = 'unnamedplus' -- Enable break indent -vim.o.breakindent = true +vim.opt.breakindent = true -- Save undo history -vim.o.undofile = true +vim.opt.undofile = true -- Case-insensitive searching UNLESS \C or capital in search -vim.o.ignorecase = true -vim.o.smartcase = true +vim.opt.ignorecase = true +vim.opt.smartcase = true -- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' +vim.opt.signcolumn = 'yes' -- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 300 - --- NOTE: You should make sure your terminal supports this -vim.o.termguicolors = true +vim.opt.updatetime = 250 +vim.opt.timeoutlen = 300 -- Configure how new splits should be opened -vim.o.splitright = true -vim.o.splitbelow = true +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Sets how neovim will display certain whitespace in the editor. +-- See :help 'list' +-- and :help 'listchars' +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- [[ Basic Keymaps ]] @@ -111,8 +137,8 @@ vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = tr vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic 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', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) @@ -123,9 +149,8 @@ vim.keymap.set('t', '', '', { desc = 'Escape Escape exits t -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) vim.api.nvim_create_autocmd('TextYankPost', { - group = highlight_group, + group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }), callback = function() vim.highlight.on_yank() end, @@ -135,43 +160,36 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then - vim.fn.system { - 'git', - 'clone', - '--filter=blob:none', - 'https://github.com/folke/lazy.nvim.git', - '--branch=stable', -- latest stable release - lazypath, - } + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } end vim.opt.rtp:prepend(lazypath) -- [[ Configure plugins ]] -- NOTE: Here is where you install your plugins. --- You can configure plugins using the `config` key. --- --- You can also configure plugins after the setup call, --- as they will be available in your neovim runtime. require('lazy').setup({ - -- NOTE: Plugins can be added by simply giving a link or 'owner/repo' link. + -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the 'owner/repo' and then following - -- keys can be used to configure plugin behavior. + -- with the first argument being the link and the following + -- keys can be used to configure plugin behavior/loading/etc. -- - -- For example, using: - -- opts = { ... } + -- Use `opts = {}` to force a plugin to be loaded. -- - -- is the same as doing: - -- require("myplugin").setup { ... } - -- - -- Lazy will automatically load and run the setup for this plugin + -- This is equivalent to: + -- require('Comment').setup({}) + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + + -- Here is a more advanced example where we pass configuration + -- options to `conform.nvim`. + -- + -- See `:help conform` to understand what the configuration keys do { -- Autoformat 'stevearc/conform.nvim', - event = 'VeryLazy', opts = { format_on_save = { timeout_ms = 500, @@ -197,7 +215,8 @@ require('lazy').setup({ -- For example, in the following configuration, we use: -- event = 'VeryLazy' -- - -- which loads which-key after all the UI elements are loaded. + -- which loads which-key after all the UI elements are loaded. Events can be + -- normal autocommands events (:help autocomd-events). -- -- Then, because we use the `config` key, the configuration only runs -- after the plugin has been loaded: @@ -205,8 +224,8 @@ require('lazy').setup({ { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', - event = 'VeryLazy', - config = function() + event = 'VeryLazy', -- Sets the loading event to 'VeryLazy' + config = function() -- This is the function that runs, AFTER loading require('which-key').setup() -- document existing key chains @@ -238,11 +257,12 @@ require('lazy').setup({ 'nvim-lua/plenary.nvim', { -- If encountering errors, see telescope-fzf-native README for install instructions 'nvim-telescope/telescope-fzf-native.nvim', - -- NOTE: `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` 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', - -- NOTE: `cond` is a condition used to determine whether this plugin should be + -- `cond` is a condition used to determine whether this plugin should be -- installed and loaded. cond = function() return vim.fn.executable 'make' == 1 @@ -256,28 +276,6 @@ require('lazy').setup({ -- { 'nvim-tree/nvim-web-devicons' } }, config = function() - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable telescope fzf native, if installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - -- 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! @@ -297,6 +295,25 @@ require('lazy').setup({ -- telescope picker. This is really useful to discover what Telescope can -- do as well as how to actually do it! + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = {}, + -- pickers = {} + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable telescope extensions, if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) @@ -308,7 +325,6 @@ require('lazy').setup({ vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme @@ -597,10 +613,16 @@ require('lazy').setup({ priority = 1000, -- make sure to load this before all the other start plugins config = function() -- load the colorscheme here - vim.cmd.colorscheme 'tokyonight' + vim.cmd.colorscheme 'tokyonight-night' + + -- You can configure highlights by doing something like + vim.cmd.hi 'Comment gui=none' end, }, + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', config = function() @@ -624,9 +646,6 @@ require('lazy').setup({ end, }, - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', @@ -650,6 +669,10 @@ require('lazy').setup({ end, }, + -- The following two 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 + -- put them in the right spots if you want. + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. From 2022a26e281c8e80cf8d4d2724f62dee471e300d Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 22 Feb 2024 14:16:49 -0500 Subject: [PATCH 07/22] for zd --- init.lua | 106 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 41 deletions(-) diff --git a/init.lua b/init.lua index 84c1f51a..bfab37c7 100644 --- a/init.lua +++ b/init.lua @@ -85,11 +85,11 @@ vim.g.maplocalleader = ' ' -- NOTE: You can change these options as you wish! -- For more options, you can see `:help option-list` --- Set highlight on search -vim.opt.hlsearch = false - -- Make line numbers default vim.opt.number = true +-- You can also add relative line numbers, for help with jumping. +-- Experiment for yourself to see if you like it! +-- vim.opt.relativenumber = true -- Enable mouse mode vim.opt.mouse = 'a' @@ -126,8 +126,17 @@ vim.opt.splitbelow = true vim.opt.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +-- Preview substitutions live +vim.opt.inccommand = 'split' + -- [[ Basic Keymaps ]] +-- Set highlight on search +vim.opt.hlsearch = true + +-- Clear highlighting on pressing Escape +vim.keymap.set('n', '', ':nohlsearch', { silent = true }) + -- Keymaps for better default experience -- See `:help vim.keymap.set()` vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) @@ -301,7 +310,11 @@ require('lazy').setup({ -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = {}, + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, -- pickers = {} extensions = { ['ui-select'] = { @@ -400,47 +413,53 @@ require('lazy').setup({ require('neodev').setup() -- This function gets run when an LSP connects to a particular buffer. - local on_attach = function(_, bufnr) - -- 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 - -- many times. - -- - -- 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 nmap = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = 'LSP: ' .. desc }) - end + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('custom-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- 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 nmap = function(keys, func, desc) + vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end - -- Important LSP Navigation keybinds - -- - -- Jump to the definition of the word under your cursor. - -- To jump back, press . - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- Important LSP Navigation keybinds + -- + -- Jump to the definition of the word under your cursor. + -- To jump back, press . + nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- NOTE: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - -- Rename the variable under your cursor - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + -- Rename the variable under your cursor + nmap('rn', 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. - nmap('ca', function() - vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } - end, '[C]ode [A]ction') + -- 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. + nmap('ca', function() + vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } + end, '[C]ode [A]ction') - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - -- Show the signature of the function you're currently completing. - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - end + -- Show the signature of the function you're currently completing. + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + end, + }) -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP Specification. @@ -462,8 +481,14 @@ require('lazy').setup({ -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, - -- tsserver = {}, -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + -- + -- If you use something like typescript, where the tooling is as bad as the language, + -- then you might need to install and configure something like this: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- If you only have simple needs for typescript, then you can probably just use tsserver + -- tsserver = {}, lua_ls = { -- cmd = {...}, @@ -495,7 +520,6 @@ require('lazy').setup({ cmd = server.cmd, settings = server.settings, filetypes = server.filetypes, - on_attach = on_attach, -- TODO: Think about what we wanna do here. -- capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities), capabilities = server.capabilities or capabilities, From ceadebd22d6612b8d95b3399ac7bced8d21c22db Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 22 Feb 2024 14:30:44 -0500 Subject: [PATCH 08/22] yes, i'm pushing updates --- init.lua | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/init.lua b/init.lua index bfab37c7..8ee93fac 100644 --- a/init.lua +++ b/init.lua @@ -425,7 +425,7 @@ require('lazy').setup({ -- -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) + local map = function(keys, func, desc) vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end @@ -433,31 +433,31 @@ require('lazy').setup({ -- -- Jump to the definition of the word under your cursor. -- To jump back, press . - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') -- Rename the variable under your cursor - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + map('rn', 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. - nmap('ca', function() + map('ca', function() vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } end, '[C]ode [A]ction') -- See `:help K` for why this keymap - nmap('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. - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + map('', vim.lsp.buf.signature_help, 'Signature Documentation') end, }) @@ -473,7 +473,7 @@ require('lazy').setup({ -- 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): TODO + -- - 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 servers = { @@ -482,6 +482,7 @@ require('lazy').setup({ -- pyright = {}, -- rust_analyzer = {}, -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- If you use something like typescript, where the tooling is as bad as the language, -- then you might need to install and configure something like this: @@ -498,20 +499,23 @@ require('lazy').setup({ Lua = { workspace = { checkThirdParty = false }, telemetry = { enable = false }, - -- NOTE: 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' } }, }, }, }, } + -- 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) + vim.list_extend(ensure_installed, { + 'stylua', + }) + -- Ensure the servers above are installed require('mason').setup() - - -- TODO: Think about lspconfig mason - local installed = { 'stylua' } - vim.list_extend(installed, vim.tbl_keys(servers)) - require('mason-tool-installer').setup { ensure_installed = installed } + require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { handlers = { function(server_name) @@ -520,9 +524,7 @@ require('lazy').setup({ cmd = server.cmd, settings = server.settings, filetypes = server.filetypes, - -- TODO: Think about what we wanna do here. - -- capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities), - capabilities = server.capabilities or capabilities, + capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities), } end, }, From 1b9467751af20982da029ecf47d5eeba177da766 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 22 Feb 2024 14:36:41 -0500 Subject: [PATCH 09/22] ok fix --- init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 8ee93fac..51d8e1e9 100644 --- a/init.lua +++ b/init.lua @@ -508,9 +508,9 @@ require('lazy').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) + local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { - 'stylua', + 'stylua', -- Used to format lua code }) -- Ensure the servers above are installed @@ -524,7 +524,7 @@ require('lazy').setup({ cmd = server.cmd, settings = server.settings, filetypes = server.filetypes, - capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities), + capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}), } end, }, From 95d8863806982bd79ff7fd0dcb4f5e49b3afae2c Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 22 Feb 2024 15:25:47 -0500 Subject: [PATCH 10/22] time to proof read --- init.lua | 64 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/init.lua b/init.lua index 51d8e1e9..d6a61da6 100644 --- a/init.lua +++ b/init.lua @@ -4,18 +4,19 @@ ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== ======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____.| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== +======== .----------------------. | === | ======== +======== |.-""""""""""""""""""-.| |-----| ======== +======== || || | === | ======== +======== || KICKSTART.NVIM || |-----| ======== +======== || || | === | ======== +======== || || |-----| ======== +======== ||:Tutor || |:::::| ======== +======== |'-..................-'| |____.| ======== +======== `"")----------------(""` ___________ ======== +======== /::::::::::| |::::::::::\ \ no mouse \ ======== +======== /:::========| |==hjkl==:::\ \ required \ ======== +======== '""""""""""""' '""""""""""""' '""""""""""' ======== +======== ======== ===================================================================== ===================================================================== @@ -174,7 +175,16 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- [[ Configure plugins ]] +-- [[ Configure and install plugins ]] +-- +-- To check the current status of your plugins, run +-- :Lazy +-- +-- You can press `?` in this menu for help. +-- +-- To update plugins, you can run +-- :Lazy update +-- -- NOTE: Here is where you install your plugins. require('lazy').setup({ @@ -378,7 +388,7 @@ require('lazy').setup({ -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', - -- Useful status updates for LSP + -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, }, @@ -514,6 +524,11 @@ require('lazy').setup({ }) -- Ensure the servers above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu require('mason').setup() require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { @@ -576,17 +591,24 @@ require('lazy').setup({ }, -- For an understanding of why these mappings were -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { -- Select the [n]ext item [''] = cmp.mapping.select_next_item(), -- Select the [p]revious item [''] = cmp.mapping.select_prev_item(), + -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. [''] = cmp.mapping.confirm { select = true }, - -- Manually trigger a completion from nvim-cmp + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. [''] = cmp.mapping.complete {}, + -- Think of as moving to the right of your snippet expansion. -- So if you have a snippet that's like: -- function $name($args) @@ -638,7 +660,7 @@ require('lazy').setup({ lazy = false, -- make sure we load this during startup if it is your main colorscheme priority = 1000, -- make sure to load this before all the other start plugins config = function() - -- load the colorscheme here + -- Load the colorscheme here vim.cmd.colorscheme 'tokyonight-night' -- You can configure highlights by doing something like @@ -655,11 +677,15 @@ require('lazy').setup({ -- Better Around/Inside textobjects -- -- Examples: - -- - `af` - around function call - -- - `inq` - inside next quote + -- - ya) - [Y]ank [A]round [)]parenthen + -- - yinq - [Y]ank [I]nside [N]ext [']quote + -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 } -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - sd' - [S]urround [D]elete [']quotes + -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup() -- Simple and easy statusline. @@ -689,7 +715,7 @@ require('lazy').setup({ -- 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 with nvim-treesitter, see :help nvim-treesitter-incremental-selection-mod + -- - Incremental selection: Included, see :help nvim-treesitter-incremental-selection-mod -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects end, From 532dbef6b42a7fd35fc08a070765e30abf72af0f Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 09:39:46 -0500 Subject: [PATCH 11/22] final stretch --- README.md | 117 +++++++++++++----------------------------------------- init.lua | 40 +++++++++++-------- 2 files changed, 51 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index b7fe337a..b2cf572b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # kickstart.nvim -https://github.com/kdheepak/kickstart.nvim/assets/1813121/f3ff9a2b-c31f-44df-a4fa-8a0d7b17cf7b - ### Introduction A starting point for Neovim that is: @@ -32,28 +30,38 @@ Neovim's configurations are located under the following paths, depending on your | OS | PATH | | :- | :--- | -| Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | +| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | | Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | | Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | Clone kickstart.nvim: -- on Linux and Mac +
+ Linux and Mac + ```sh git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim ``` -- on Windows (cmd) +
+ +
+ Windows + +If you're using `cmd.exe`: + ``` git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ ``` -- on Windows (powershell) +If you're using `powershell.exe` + ``` git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ ``` +
+ ### Post Installation @@ -63,13 +71,9 @@ Start Neovim nvim ``` -The `Lazy` plugin manager will start automatically on the first run and install the configured plugins - as can be seen in the introduction video. After the installation is complete you can press `q` to close the `Lazy` UI and **you are ready to go**! Next time you run nvim `Lazy` will no longer show up. +That's it! Lazy will install all the plugins you have. Use `:Lazy` to view current plugin status. -If you would prefer to hide this step and run the plugin sync from the command line, you can use: - -```sh -nvim --headless "+Lazy! sync" +qa -``` +Read through the `init.lua` file in your configuration folder for more information about extending and exploring Neovim. ### Getting Started @@ -82,18 +86,12 @@ See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the > **NOTE** > Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` -### Configuration And Extension +#### Examples of adding popularly requested plugins -* Inside of your copy, feel free to modify any file you like! It's your copy! -* Feel free to change any of the default options in `init.lua` to better suit your needs. -* For adding plugins, there are 3 primary options: - * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` (uncomment the line importing the `custom/plugins` directory in the `init.lua` file to enable this) - * Modify `init.lua` with additional plugins. - * Include the `lua/kickstart/plugins/*` files in your configuration. +
+ Adding autopairs -You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration. - -#### Example: Adding an autopairs plugin +This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). In the file: `lua/custom/plugins/autopairs.lua`, add: @@ -118,9 +116,13 @@ return { ``` -This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). -#### Example: Adding a file tree plugin +
+ +
+ Adding a file tree plugin + +This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. In the file: `lua/custom/plugins/filetree.lua`, add: @@ -142,23 +144,13 @@ return { } ``` -This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. - -### Contribution - -Pull-requests are welcome. The goal of this repo is not to create a Neovim configuration framework, but to offer a starting template that shows, by example, available features in Neovim. Some things that will not be included: - -* Custom language server configuration (null-ls templates) -* Theming beyond a default colorscheme necessary for LSP highlight groups - -Each PR, especially those which increase the line count, should have a description as to why the PR is necessary. +
### FAQ * What should I do if I already have a pre-existing neovim configuration? * You should back it up, then delete all files associated with it. * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` - * You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide) * Can I keep my existing configuration in parallel to kickstart? * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create an alias: ``` @@ -191,56 +183,3 @@ This requires: ```lua {'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } ``` - -### Hints And Tips For New Neovimmers - -Neovim is a very rich and powerful environment, but it can also feel a bit -intimidating for new users trying to find their way around, especially if -they're coming from other environments like Visual Studio Code or a traditional -IDE. - -There's no way this README can provide you with everything you need to know, but -here are a few tips so you can learn how to learn. - -### Use The Help, Luke! - -Neovim's help system is incredibly thorough and extensive. You should really -take a moment to get comfortable navigating through help topics, going back and -forth, navigating the menus, etc. This won't just help you read the help, it -will empower you in the rest of your Neovim journey. - -You can double click on a topic to drill down, and hit Ctrl-o (Hold down the -Control key and the 'o' key) to go back. - -Read the first page you get when you run :help carefully. it will serve you -well. - -You can also get help on a particular thing by typing ":help ". - -Like, let's say we want to learn more about folding, just type ":help folding". - -### To The Telescope! - -One of the more powerful features you get by installing this project is the -brilliant Telescope plugin co-written by @tjdevries. - -Take a minute to browse through ":help telescope" and get a sense for all the -amazing superpowers you've gained. - -In particular, there are two Telescope features that are incredible for helping -you understand how to do a particular thing or how to configure a particular -feature. - -If you're not sure what to look for, try ":Telescope help_tags". Let's say we -want to configure Neovim to automatically word wrap. We might type ":Telescope -help_tags" and then type w, r, a, p. Notice how the list of results changes with -each new letter you type? When you're done you've got a screen full of topics -involving word wrap. - -Another common question is "What keys do I hit to make a thing happen?". To get -an answer, one way is to use ":Telescope keymaps". You'll get the same list of -results that changes to adapt with each new key you press. - -With these hints in mind you should be in good shape to get learning. Remember, -you are on a journey of discovery here, adapting your programming environment to -your needs. It will take effort, but the rewards are worth it! :) diff --git a/init.lua b/init.lua index d6a61da6..73f5fa80 100644 --- a/init.lua +++ b/init.lua @@ -11,7 +11,7 @@ ======== || || | === | ======== ======== || || |-----| ======== ======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____.| ======== +======== |'-..................-'| |____o| ======== ======== `"")----------------(""` ___________ ======== ======== /::::::::::| |::::::::::\ \ no mouse \ ======== ======== /:::========| |==hjkl==:::\ \ required \ ======== @@ -22,19 +22,22 @@ Kickstart.nvim is *not* a distribution. -Kickstart.nvim is a template for your own configuration. +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 should start exploring, configuring and tinkering to - explore Neovim! + 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: - - https://learnxinyminutes.com/docs/lua/ + a guide. One possible example which will only take 10-15 minutes: + - https://learnxinyminutes.com/docs/lua/ - And then you can explore or search through `:help lua-guide` - - https://neovim.io/doc/user/lua-guide.html + 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: @@ -385,9 +388,6 @@ require('lazy').setup({ 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', - -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, @@ -418,10 +418,6 @@ require('lazy').setup({ -- If you're wondering about lsp vs treesitter, you can check out the wonderfully -- and elegantly composed help section, :help lsp-vs-treesitter - -- First, enable neodev. This is helpful for auto-configuring the Lua LSP - -- to understand your Neovim environment - require('neodev').setup() - -- This function gets run when an LSP connects 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 @@ -507,7 +503,16 @@ require('lazy').setup({ -- capabilities = {}, settings = { Lua = { - workspace = { checkThirdParty = false }, + runtime = { version = 'LuaJIT' }, + workspace = { + checkThirdParty = false, + 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 }, + }, telemetry = { enable = false }, -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- diagnostics = { disable = { 'missing-fields' } }, @@ -677,12 +682,13 @@ require('lazy').setup({ -- Better Around/Inside textobjects -- -- Examples: - -- - ya) - [Y]ank [A]round [)]parenthen + -- - va) - [V]isually select [A]round [)]parenthen -- - yinq - [Y]ank [I]nside [N]ext [']quote -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 } -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] From 65cbba91abcecd0b27727a1e1e5d865600d838dd Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 12:51:28 -0500 Subject: [PATCH 12/22] yayaya --- init.lua | 164 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 102 insertions(+), 62 deletions(-) diff --git a/init.lua b/init.lua index 73f5fa80..64004825 100644 --- a/init.lua +++ b/init.lua @@ -20,28 +20,31 @@ ===================================================================== ===================================================================== -Kickstart.nvim is *not* a distribution. +What is Kickstart? -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. + Kickstart.nvim is *not* a distribution. - 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! + 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. - 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/ + 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! - 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 + 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: - 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: - - : @@ -60,11 +63,12 @@ Kickstart Guide: 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 "sh" to [s]earch the [h]elp documentation, + MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, 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 - 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 @@ -80,7 +84,7 @@ P.S. You can delete this when you're done too. It's your config now! :) -- Set as the leader key -- See `:help mapleader` --- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' @@ -95,9 +99,12 @@ vim.opt.number = true -- Experiment for yourself to see if you like it! -- vim.opt.relativenumber = true --- Enable mouse mode +-- Enable mouse mode, can be useful for resizing splits for example! 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. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` @@ -130,40 +137,56 @@ vim.opt.splitbelow = true vim.opt.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } --- Preview substitutions live +-- Preview substitutions live, as you type! vim.opt.inccommand = 'split' +-- Show which line your cursor is on +vim.opt.cursorline = true + +-- Minimal number of screen lines to keep above and below the cursor. +vim.opt.scrolloff = 10 + -- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` --- Set highlight on search +-- Set highlight on search, but clear on pressing in normal mode vim.opt.hlsearch = true - --- Clear highlighting on pressing Escape -vim.keymap.set('n', '', ':nohlsearch', { silent = true }) - --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', '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 --- for people to discover. Otherwise, you normally need to press , which +-- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. -vim.keymap.set('t', '', '', { desc = 'Escape Escape exits terminal mode' }) +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` +-- TIP: Disable arrow keys in normal mode +-- vim.keymap.set('n', '', 'echo "Use h to move!!"') +-- vim.keymap.set('n', '', 'echo "Use l to move!!"') +-- vim.keymap.set('n', '', 'echo "Use k to move!!"') +-- vim.keymap.set('n', '', 'echo "Use j to move!!"') + +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` vim.api.nvim_create_autocmd('TextYankPost', { - group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }), + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() vim.highlight.on_yank() end, @@ -175,7 +198,7 @@ local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } -end +end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) -- [[ Configure and install plugins ]] @@ -183,7 +206,7 @@ vim.opt.rtp:prepend(lazypath) -- To check the current status of your plugins, run -- :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 -- :Lazy update @@ -207,12 +230,14 @@ require('lazy').setup({ { 'numToStr/Comment.nvim', opts = {} }, -- Here is a more advanced example where we pass configuration - -- options to `conform.nvim`. + -- options to `conform.nvim`. This is equivalent to: + -- require('conform').setup({ ... }) -- -- See `:help conform` to understand what the configuration keys do { -- Autoformat 'stevearc/conform.nvim', opts = { + notify_on_error = false, format_on_save = { timeout_ms = 500, lsp_fallback = true, @@ -250,15 +275,12 @@ require('lazy').setup({ config = function() -- This is the function that runs, AFTER loading require('which-key').setup() - -- document existing key chains + -- Document existing key chains require('which-key').register { ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, } end, @@ -363,7 +385,7 @@ require('lazy').setup({ end, { desc = '[/] Fuzzily search in current buffer' }) -- Also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular pickers + -- See `:help telescope.builtin.live_grep()` for information about particular keys vim.keymap.set('n', 's/', function() builtin.live_grep { grep_open_files = true, @@ -383,7 +405,7 @@ require('lazy').setup({ { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { - -- Automatically install LSPs to stdpath for neovim + -- Automatically install LSPs and related tools to stdpath for neovim 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', @@ -413,17 +435,17 @@ require('lazy').setup({ -- - and more! -- -- 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 -- and elegantly composed help section, :help lsp-vs-treesitter - -- This function gets run when an LSP connects to a particular buffer. + -- This function gets run when an LSP attaches to a particular buffer. -- That is to say, every time a new file is opened that is associated with -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this -- function will be executed to configure the current buffer vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('custom-lsp-attach', { clear = true }), + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) -- NOTE: Remember that lua is a real programming language, and as such it is possible -- to define small helper and utility functions so you don't have to repeat yourself @@ -435,22 +457,33 @@ require('lazy').setup({ vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- Important LSP Navigation keybinds - -- -- 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 . 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') + + -- 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') + + -- 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 it's *type*, not where it was *defined*. map('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('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace + -- Similar to document symbols, except searches over your whole project. map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - -- Rename the variable under your cursor + -- Most Language Servers support renaming across files, etc. map('rn', vim.lsp.buf.rename, '[R]e[n]ame') -- Execute a code action, usually your cursor needs to be on top of an error @@ -459,19 +492,25 @@ require('lazy').setup({ 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') -- Show the signature of the function you're currently completing. map('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') end, }) -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP Specification. -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilties with nvim cmp, and then broadcast that to the servers. - local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + 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 -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. @@ -506,6 +545,8 @@ require('lazy').setup({ runtime = { version = 'LuaJIT' }, workspace = { checkThirdParty = 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)), @@ -513,7 +554,6 @@ require('lazy').setup({ -- If lua_ls is really slow on your computer, you can try this instead: -- library = { vim.env.VIMRUNTIME }, }, - telemetry = { enable = false }, -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- diagnostics = { disable = { 'missing-fields' } }, }, @@ -731,7 +771,7 @@ require('lazy').setup({ -- 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. - -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. -- require 'kickstart.plugins.debug', From bad5a2d0b8360a9c62dd9767507035d1a54c381b Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 13:45:18 -0500 Subject: [PATCH 13/22] finished? please test --- init.lua | 42 ++++++++++++++++++++------- lazy-lock.json | 13 ++++----- lua/kickstart/plugins/indent_line.lua | 9 ++++++ 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 lua/kickstart/plugins/indent_line.lua diff --git a/init.lua b/init.lua index 64004825..3af78518 100644 --- a/init.lua +++ b/init.lua @@ -471,7 +471,7 @@ require('lazy').setup({ -- 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 it's *type*, not where it was *defined*. + -- the definition of its *type*, not where it was *defined*. map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') -- Fuzzy find all the symbols in your current document. @@ -502,6 +502,21 @@ require('lazy').setup({ -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- 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). + 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, }) @@ -526,7 +541,6 @@ require('lazy').setup({ -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- If you use something like typescript, where the tooling is as bad as the language, @@ -568,7 +582,7 @@ require('lazy').setup({ 'stylua', -- Used to format lua code }) - -- Ensure the servers above are installed + -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install -- other tools, you can run -- :Mason @@ -584,6 +598,9 @@ require('lazy').setup({ cmd = server.cmd, settings = server.settings, 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 {}), } end, @@ -611,18 +628,22 @@ require('lazy').setup({ }, '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-path', - -- Adds a number of user-friendly snippets - 'rafamadriz/friendly-snippets', + -- If you want to add a bunch of pre-configured 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() -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' - require('luasnip.loaders.from_vscode').lazy_load() luasnip.config.setup {} cmp.setup { @@ -631,9 +652,8 @@ require('lazy').setup({ luasnip.lsp_expand(args.body) end, }, - completion = { - completeopt = 'menu,menuone,noinsert,noselect', - }, + completion = { completeopt = 'menu,menuone,noinsert' }, + -- For an understanding of why these mappings were -- chosen, you will need to read `:help ins-completion` -- @@ -771,7 +791,7 @@ require('lazy').setup({ -- 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. - -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "" for kickstart + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional plugins for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. -- require 'kickstart.plugins.debug', diff --git a/lazy-lock.json b/lazy-lock.json index 79a76e7d..499056c8 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -8,22 +8,21 @@ "fidget.nvim": { "branch": "main", "commit": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa" }, "friendly-snippets": { "branch": "main", "commit": "dbd45e9ba76d535e4cba88afa1b7aa43bb765336" }, "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, - "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, - "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, - "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "kanagawa.nvim": { "branch": "master", "commit": "ab41956c4559c3eb21e713fcdf54cda1cb6d5f40" }, + "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "60f6805b12a12e8a912aeb2f975dec1794a8994e" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "1212fb6082b7177dde17ea65e429e027835aeb40" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "mini.nvim": { "branch": "main", "commit": "0bc73241cd9c686d80ab28f4af2c04e626fb2304" }, "neodev.nvim": { "branch": "main", "commit": "bbe17de89345ce40725e721d347c596dc4a02b32" }, "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, "nvim-lspconfig": { "branch": "master", "commit": "1699ce10c3aaf861cfa0c1303fcd19d2ed93e7ad" }, "nvim-treesitter": { "branch": "master", "commit": "6bd108a6f10aa01b854c3c673b6d9d61662a8c93" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" }, "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" }, - "vim-fugitive": { "branch": "master", "commit": "011cf4fcb93a9649ffc6dcdff56ef948f5d0f7cc" }, - "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } } \ No newline at end of file diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua new file mode 100644 index 00000000..ed7f2693 --- /dev/null +++ b/lua/kickstart/plugins/indent_line.lua @@ -0,0 +1,9 @@ +return { + { -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help ibl` + main = 'ibl', + opts = {}, + }, +} From dacbbf59c211f11f244bf97ff4e499dc0b1c5f18 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 13:46:14 -0500 Subject: [PATCH 14/22] remove lazy lock --- .gitignore | 3 +++ lazy-lock.json | 28 ---------------------------- 2 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 lazy-lock.json diff --git a/.gitignore b/.gitignore index d699e1d6..005b535b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ tags test.sh .luarc.json nvim + +spell/ +lazy-lock.json diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 499056c8..00000000 --- a/lazy-lock.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "4c01323a67f1636d73803aad4e8e735bad7a9561" }, - "fidget.nvim": { "branch": "main", "commit": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa" }, - "friendly-snippets": { "branch": "main", "commit": "dbd45e9ba76d535e4cba88afa1b7aa43bb765336" }, - "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, - "kanagawa.nvim": { "branch": "master", "commit": "ab41956c4559c3eb21e713fcdf54cda1cb6d5f40" }, - "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "60f6805b12a12e8a912aeb2f975dec1794a8994e" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "1212fb6082b7177dde17ea65e429e027835aeb40" }, - "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, - "mini.nvim": { "branch": "main", "commit": "0bc73241cd9c686d80ab28f4af2c04e626fb2304" }, - "neodev.nvim": { "branch": "main", "commit": "bbe17de89345ce40725e721d347c596dc4a02b32" }, - "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, - "nvim-lspconfig": { "branch": "master", "commit": "1699ce10c3aaf861cfa0c1303fcd19d2ed93e7ad" }, - "nvim-treesitter": { "branch": "master", "commit": "6bd108a6f10aa01b854c3c673b6d9d61662a8c93" }, - "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, - "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } -} \ No newline at end of file From 48c88b73bea2197927fcf4aaee88df83524413cc Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 14:02:48 -0500 Subject: [PATCH 15/22] force lua install --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 3af78518..b17ddae4 100644 --- a/init.lua +++ b/init.lua @@ -772,6 +772,7 @@ require('lazy').setup({ ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { + ensure_installed = { 'lua' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = true, highlight = { enable = true }, From 9837e7ed389aa7333946fa6919d4a86537bccecf Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 14:07:36 -0500 Subject: [PATCH 16/22] force lua install an rest --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index b17ddae4..2ae31e13 100644 --- a/init.lua +++ b/init.lua @@ -772,7 +772,7 @@ require('lazy').setup({ ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { - ensure_installed = { 'lua' }, + ensure_installed = { 'c', 'help', 'lua', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = true, highlight = { enable = true }, From 0f8eb177da47f1b591cdd32f9b356f9e189981a2 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 15:18:25 -0500 Subject: [PATCH 17/22] fixup: remove help, it's vimdoc --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 2ae31e13..0cd020e1 100644 --- a/init.lua +++ b/init.lua @@ -772,7 +772,7 @@ require('lazy').setup({ ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { - ensure_installed = { 'c', 'help', 'lua', 'vim', 'vimdoc' }, + ensure_installed = { 'c', 'lua', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = true, highlight = { enable = true }, From 51842d80648e13a00d0b898a8db5ebc9d4f779cf Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 23 Feb 2024 16:53:32 -0500 Subject: [PATCH 18/22] fixup: update docs and check deps --- README.md | 59 ++++++++++++++++++++++++++++++++----------------------- init.lua | 2 +- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index b2cf572b..c9b9d84e 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,39 @@ # kickstart.nvim -### Introduction +## Introduction A starting point for Neovim that is: * Small -* Single-file (with examples of moving to multi-file) -* Documented -* Modular +* Single-file +* Completely Documented -This repo is meant to be used by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. +**NOT** a Neovim distribution, but instead a starting point for your configuration. -Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. If you are experiencing issues, please make sure you have the latest versions. +## Installation -Distribution Alternatives: -- [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) +### Install Neovim -### Installation +Kickstart.nvim targets *only* the latest +['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest +['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. +If you are experiencing issues, please make sure you have the latest versions. + +### Install External Dependencies > **NOTE** > [Backup](#FAQ) your previous configuration (if any exists) -Requirements: -* Make sure to review the readmes of the plugins if you are experiencing errors. In particular: - * [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers. -* See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native` +External Requirements: +- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) +- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) +- Language Setup: + - If want to write Typescript, you need `npm` + - If want to write Golang, you will need `go` + - etc. + +> **NOTE** +> See [Windows Installation](#Windows-Installation) to double check any additional Windows notes Neovim's configurations are located under the following paths, depending on your OS: @@ -36,8 +45,7 @@ Neovim's configurations are located under the following paths, depending on your Clone kickstart.nvim: -
- Linux and Mac +
Linux and Mac ```sh git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim @@ -45,8 +53,7 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO
-
- Windows +
Windows If you're using `cmd.exe`: @@ -62,7 +69,6 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppDat
- ### Post Installation Start Neovim @@ -71,17 +77,23 @@ Start Neovim nvim ``` -That's it! Lazy will install all the plugins you have. Use `:Lazy` to view current plugin status. +That's it! Lazy will install all the plugins you have. Use `:Lazy` to view +current plugin status. -Read through the `init.lua` file in your configuration folder for more information about extending and exploring Neovim. +Read through the `init.lua` file in your configuration folder for more +information about extending and exploring Neovim. ### Getting Started -See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the previous version. Note: The install via init.lua is outdated, please follow the install instructions in this file instead. An updated video is coming soon. +See [Effective Neovim: Instant IDE](https://youtu.be/stqUbv-5u2s), covering the +previous version. Note: The install via init.lua is outdated, please follow the +install instructions in this file instead. An updated video is coming soon. ### Recommended Steps -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo (so that you have your own copy that you can modify) and then installing you can install to your machine using the methods above. +[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo +(so that you have your own copy that you can modify) and then installing you +can install to your machine using the methods above. > **NOTE** > Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` @@ -115,10 +127,7 @@ return { } ``` - -
-
Adding a file tree plugin diff --git a/init.lua b/init.lua index 0cd020e1..4fdf2a44 100644 --- a/init.lua +++ b/init.lua @@ -620,7 +620,7 @@ require('lazy').setup({ -- 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 then + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end return 'make install_jsregexp' From 1e3ba58a40dde8e68152e13d29137dc507bf56ce Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Sat, 24 Feb 2024 23:15:25 -0500 Subject: [PATCH 19/22] add capabilities check --- init.lua | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index 4fdf2a44..f9be842f 100644 --- a/init.lua +++ b/init.lua @@ -395,9 +395,7 @@ require('lazy').setup({ -- Shortcut for searching your neovim configuration files vim.keymap.set('n', 'sn', function() - builtin.find_files { - cwd = vim.fn.stdpath 'config', - } + builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' }) end, }, @@ -488,9 +486,7 @@ require('lazy').setup({ -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. - map('ca', function() - vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } - end, '[C]ode [A]ction') + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap @@ -508,15 +504,18 @@ require('lazy').setup({ -- See `:help CursorHold` for information about when this is executed -- -- When you move your cursor, the highlights will be cleared (the second autocommand). - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - callback = vim.lsp.buf.document_highlight, - }) + 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, - }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + callback = vim.lsp.buf.clear_references, + }) + end end, }) From 5775433158480966a4ace022c0cd8ca5197166dd Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Sat, 24 Feb 2024 23:17:19 -0500 Subject: [PATCH 20/22] add some more grammars for readme --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index f9be842f..cf320ac1 100644 --- a/init.lua +++ b/init.lua @@ -771,7 +771,7 @@ require('lazy').setup({ ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { - ensure_installed = { 'c', 'lua', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = true, highlight = { enable = true }, From 30a1ccc89b374d67caadc2d831c6d4cb0b239fb3 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Mon, 26 Feb 2024 08:55:52 -0500 Subject: [PATCH 21/22] health check --- init.lua | 6 ++--- lua/kickstart/health.lua | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 lua/kickstart/health.lua diff --git a/init.lua b/init.lua index cf320ac1..72231f90 100644 --- a/init.lua +++ b/init.lua @@ -542,12 +542,12 @@ require('lazy').setup({ -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- - -- If you use something like typescript, where the tooling is as bad as the language, - -- then you might need to install and configure something like this: + -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- - -- If you only have simple needs for typescript, then you can probably just use tsserver + -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, + -- lua_ls = { -- cmd = {...}, diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua new file mode 100644 index 00000000..9547c3a2 --- /dev/null +++ b/lua/kickstart/health.lua @@ -0,0 +1,48 @@ +--[[ +-- +-- This file is not required for your own configuration, +-- but helps people determine if their system is setup correctly. +-- +--]] + +local check_version = function() + if not vim.version.cmp then + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", tostring(vim.version()))) + return + end + + if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then + vim.health.ok(string.format("Neovim version is: '%s'", tostring(vim.version()))) + else + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", tostring(vim.version()))) + end +end + +local check_external_reqs = function() + -- Basic utils: `git`, `make`, `unzip` + for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do + local is_executable = vim.fn.executable(exe) == 1 + if is_executable then + vim.health.ok(string.format("Found executable: '%s'", exe)) + else + vim.health.warn(string.format("Could not find executable: '%s'", exe)) + end + end + + return true +end + +return { + check = function() + vim.health.start 'kickstart.nvim' + + vim.health.info [[You don't have to fix every 'WARNING' you see in checkheath." + Just fix the ones for the plugins and languages you intend to use.' + For example, in Mason, you may see warnings about several language runtimes' + but if you are not planning on developing in those languages, you do not have' + to fix those at this time']] + + check_version() + check_external_reqs() + end, +} From 8ff0f35da1873d997c7e912db2a6a57cecd06fbe Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Mon, 26 Feb 2024 09:53:08 -0500 Subject: [PATCH 22/22] finally done --- init.lua | 100 +++++++++++++++++++-------------------- lua/kickstart/health.lua | 13 +++-- 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/init.lua b/init.lua index 72231f90..0d19b081 100644 --- a/init.lua +++ b/init.lua @@ -72,10 +72,12 @@ Kickstart Guide: 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 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, - TJ @@ -230,26 +232,19 @@ require('lazy').setup({ { 'numToStr/Comment.nvim', opts = {} }, -- Here is a more advanced example where we pass configuration - -- options to `conform.nvim`. This is equivalent to: - -- require('conform').setup({ ... }) + -- options to `gitsigns.nvim`. This is equivalent to the following lua: + -- require('gitsigns').setup({ ... }) -- - -- See `:help conform` to understand what the configuration keys do - { -- Autoformat - 'stevearc/conform.nvim', + -- See `:help gitsigns` to understand what the configuration keys do + { -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.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" } }, + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, }, }, }, @@ -492,9 +487,6 @@ require('lazy').setup({ -- See `:help K` for why this keymap map('K', vim.lsp.buf.hover, 'Hover Documentation') - -- Show the signature of the function you're currently completing. - map('', vim.lsp.buf.signature_help, 'Signature Documentation') - -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') @@ -574,13 +566,6 @@ require('lazy').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 - }) - -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install -- other tools, you can run @@ -588,7 +573,15 @@ require('lazy').setup({ -- -- You can press `g?` for help in this menu 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-lspconfig').setup { handlers = { function(server_name) @@ -608,6 +601,26 @@ require('lazy').setup({ 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" } }, + }, + }, + }, + { -- Autocompletion 'hrsh7th/nvim-cmp', event = 'InsertEnter', @@ -701,20 +714,6 @@ require('lazy').setup({ 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. -- Change the name of the colorscheme plugin below, and then -- change the command in the config to whatever the name of that colorscheme is @@ -791,18 +790,19 @@ require('lazy').setup({ -- 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. - -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional plugins for kickstart - -- These are some example plugins that I've included in the kickstart repository. - -- Uncomment any of the lines below to enable them. + -- 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.indent_line', -- 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 - -- 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. + -- This is the easiest way to modularize your config. -- - -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins + -- 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' }, }, {}) diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua index 9547c3a2..957204e8 100644 --- a/lua/kickstart/health.lua +++ b/lua/kickstart/health.lua @@ -36,11 +36,14 @@ return { check = function() vim.health.start 'kickstart.nvim' - vim.health.info [[You don't have to fix every 'WARNING' you see in checkheath." - Just fix the ones for the plugins and languages you intend to use.' - For example, in Mason, you may see warnings about several language runtimes' - but if you are not planning on developing in those languages, you do not have' - to fix those at this time']] + vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth` + + Fix only warnings for plugins and languages you intend to use. + Mason will give warnings for languages that are not installed. + You do not need to install, unless you want to use those languages!]] + + local uv = vim.uv or vim.loop + vim.health.info('System Information: ' .. vim.inspect(uv.os_uname())) check_version() check_external_reqs()