From 89f79e2c5792411abb3e504599aa10991fff3e74 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 00:43:02 +0200 Subject: [PATCH 01/37] add plugin import --- init.lua | 2 +- init.vim | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 init.vim diff --git a/init.lua b/init.lua index 88658ef3033..0e986463f60 100644 --- a/init.lua +++ b/init.lua @@ -885,7 +885,7 @@ require('lazy').setup({ -- -- 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' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/init.vim b/init.vim new file mode 100644 index 00000000000..e69de29bb2d From 9626f574d11111d0ea8d65b36cc14d8fc55f6c5e Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 00:50:39 +0200 Subject: [PATCH 02/37] remove init.vim --- init.vim | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 init.vim diff --git a/init.vim b/init.vim deleted file mode 100644 index e69de29bb2d..00000000000 From 9f25cc1912724f208a5a9da8dc806051909efd73 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 09:11:34 +0200 Subject: [PATCH 03/37] add typescript lsp --- init.lua | 2 +- lua/custom/plugins/harpoon.lua | 57 +++++++++++++++++++++++++ lua/custom/plugins/typescript-tools.lua | 5 +++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/typescript-tools.lua diff --git a/init.lua b/init.lua index 0e986463f60..dba84fc9ddb 100644 --- a/init.lua +++ b/init.lua @@ -575,7 +575,7 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, + tsserver = {}, -- lua_ls = { diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000000..f4aa12ca2e1 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,57 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + harpoon:setup {} + + -- basic telescope configuration + local conf = require('telescope.config').values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table { + results = file_paths, + }, + previewer = conf.file_previewer {}, + sorter = conf.generic_sorter {}, + }) + :find() + end + + vim.keymap.set('n', '', function() + toggle_telescope(harpoon:list()) + end, { desc = 'Open harpoon window' }) + + vim.keymap.set('n', 'a', function() + harpoon:list():add() + end) + vim.keymap.set('n', '', function() + harpoon:list():select(1) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(2) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(3) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(4) + end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', '', function() + harpoon:list():prev() + end) + vim.keymap.set('n', '', function() + harpoon:list():next() + end) + end, +} diff --git a/lua/custom/plugins/typescript-tools.lua b/lua/custom/plugins/typescript-tools.lua new file mode 100644 index 00000000000..ba7fb2046e7 --- /dev/null +++ b/lua/custom/plugins/typescript-tools.lua @@ -0,0 +1,5 @@ +return { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + opts = {}, +} From 0ba62858086ad0563529cdc1e6b7487ece1875e9 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 09:50:15 +0200 Subject: [PATCH 04/37] organize nvim config --- autocommands.lua | 13 + init.lua | 913 +---------------------------------------------- keymaps.lua | 30 ++ plugins.lua | 703 ++++++++++++++++++++++++++++++++++++ set.lua | 79 ++++ 5 files changed, 829 insertions(+), 909 deletions(-) create mode 100644 autocommands.lua create mode 100644 keymaps.lua create mode 100644 plugins.lua create mode 100644 set.lua diff --git a/autocommands.lua b/autocommands.lua new file mode 100644 index 00000000000..533cb3c2472 --- /dev/null +++ b/autocommands.lua @@ -0,0 +1,13 @@ +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/init.lua b/init.lua index dba84fc9ddb..e0a7d802e7c 100644 --- a/init.lua +++ b/init.lua @@ -1,912 +1,7 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - --- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false - --- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.opt.number = true --- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true - --- 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 the 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'` -vim.opt.clipboard = 'unnamedplus' - --- Enable break indent -vim.opt.breakindent = true - --- Save undo history -vim.opt.undofile = true - --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true -vim.opt.smartcase = true - --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' - --- Decrease update time -vim.opt.updatetime = 250 - --- Decrease mapped sequence wait time --- Displays which-key popup sooner -vim.opt.timeoutlen = 300 - --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true - --- Sets how neovim will display certain whitespace characters in the editor. --- See `:help 'list'` --- and `:help 'listchars'` -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - --- 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, but clear on pressing in normal mode -vim.opt.hlsearch = 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 = '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 --- is not what someone will guess without a bit more experience. --- --- 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' }) - --- 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' }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - 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 - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) - --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. -require('lazy').setup({ - -- NOTE: Plugins can be added 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 link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - -- 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 `gitsigns.nvim`. This is equivalent to the following Lua: - -- require('gitsigns').setup({ ... }) - -- - -- 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 = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run Lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `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 = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - 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' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, - } - -- visual mode - require('which-key').register({ - ['h'] = { 'Git [H]unk' }, - }, { mode = 'v' }) - 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 = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', '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', '', 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 the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', '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', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, - - -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - { 'folke/neodev.nvim', opts = {} }, - }, - config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- 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 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. - -- 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 entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- 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 - -- or a suggestion from your LSP for this to activate. - 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. - map('K', vim.lsp.buf.hover, 'Hover 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') - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.server_capabilities.documentHighlightProvider then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- The following autocommand is used to enable inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) - end, '[T]oggle Inlay [H]ints') - end - 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 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. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - tsserver = {}, - -- - - lua_ls = { - -- cmd = {...}, - -- filetypes = { ...}, - -- capabilities = {}, - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - }, - }, - }, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - 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) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, - - { -- Autoformat - 'stevearc/conform.nvim', - lazy = false, - keys = { - { - 'f', - function() - require('conform').format { async = true, lsp_fallback = true } - end, - mode = '', - desc = '[F]ormat buffer', - }, - }, - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } - end, - 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', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - -- `friendly-snippets` contains a variety of premade snippets. - -- See the README about individual language/framework/plugin snippets: - -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, - }, - }, - 'saadparwaiz1/cmp_luasnip', - - -- 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', - }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- 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(), - - -- Scroll the documentation window [b]ack / [f]orward - [''] = 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 }, - - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), - - -- 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) - -- $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() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, - } - end, - }, - - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' - - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' - end, - }, - - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - 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. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, - { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - config = function(_, opts) - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - -- Prefer git instead of curl in order to improve connectivity in some environments - require('nvim-treesitter.install').prefer_git = true - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup(opts) - - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - end, - }, - - -- 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 - -- place them in the correct locations. - - -- 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', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps - - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - { import = 'custom.plugins' }, -}, { - ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the - -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table - icons = vim.g.have_nerd_font and {} or { - cmd = '⌘', - config = '🛠', - event = '📅', - ft = '📂', - init = '⚙', - keys = '🗝', - plugin = '🔌', - runtime = '💻', - require = '🌙', - source = '📄', - start = '🚀', - task = '📌', - lazy = '💤 ', - }, - }, -}) +require 'set' +require 'keymaps' +require 'autocommands' +require 'plugins' -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/keymaps.lua b/keymaps.lua new file mode 100644 index 00000000000..ca7abcca2d2 --- /dev/null +++ b/keymaps.lua @@ -0,0 +1,30 @@ +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- clear higlight on search on pressing in normal mode +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 = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- 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' }) + +-- 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' }) diff --git a/plugins.lua b/plugins.lua new file mode 100644 index 00000000000..c4904702504 --- /dev/null +++ b/plugins.lua @@ -0,0 +1,703 @@ +-- [[ 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 + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } +end ---@diagnostic disable-next-line: undefined-field +vim.opt.rtp:prepend(lazypath) + +-- [[ Configure and install plugins ]] +-- +-- To check the current status of your plugins, run +-- :Lazy +-- +-- You can press `?` in this menu for help. Use `:q` to close the window +-- +-- To update plugins you can run +-- :Lazy update +-- +-- NOTE: Here is where you install your plugins. +require('lazy').setup({ + -- NOTE: Plugins can be added 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 link and the following + -- keys can be used to configure plugin behavior/loading/etc. + -- + -- Use `opts = {}` to force a plugin to be loaded. + -- + -- 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 `gitsigns.nvim`. This is equivalent to the following Lua: + -- require('gitsigns').setup({ ... }) + -- + -- 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 = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, + }, + + -- NOTE: Plugins can also be configured to run Lua code when they are loaded. + -- + -- This is often very useful to both group configuration, as well as handle + -- lazy loading plugins that don't need to be loaded immediately at startup. + -- + -- For example, in the following configuration, we use: + -- event = 'VimEnter' + -- + -- which loads which-key before all the UI elements are loaded. Events can be + -- normal autocommands events (`:help autocmd-events`). + -- + -- Then, because we use the `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 = 'VimEnter', -- Sets the loading event to 'VimEnter' + config = function() -- This is the function that runs, AFTER loading + 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' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, + ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, + ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + } + -- visual mode + require('which-key').register({ + ['h'] = { 'Git [H]unk' }, + }, { mode = 'v' }) + 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 = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use Telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of `help_tags` options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in Telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- Telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! + + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', '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', '', 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 the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', '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', + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP. + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + { 'folke/neodev.nvim', opts = {} }, + }, + config = function() + -- Brief aside: **What is LSP?** + -- + -- LSP is an initialism you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that Lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc) + vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- 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 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. + -- 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 entire project. + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- 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 + -- or a suggestion from your LSP for this to activate. + 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. + map('K', vim.lsp.buf.hover, 'Hover 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') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.server_capabilities.documentHighlightProvider then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end + + -- The following autocommand is used to enable inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + end, '[T]oggle Inlay [H]ints') + end + 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 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. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`tsserver`) will work just fine + tsserver = {}, + -- + + lua_ls = { + -- cmd = {...}, + -- filetypes = { ...}, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } + + -- Ensure the servers and tools above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + 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) + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for tsserver) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, + }, + + { -- Autoformat + 'stevearc/conform.nvim', + lazy = false, + keys = { + { + 'f', + function() + require('conform').format { async = true, lsp_fallback = true } + end, + mode = '', + desc = '[F]ormat buffer', + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. + local disable_filetypes = { c = true, cpp = true } + return { + timeout_ms = 500, + lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], + } + end, + 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', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + 'L3MON4D3/LuaSnip', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + }, + 'saadparwaiz1/cmp_luasnip', + + -- 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', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + + -- 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(), + + -- Scroll the documentation window [b]ack / [f]orward + [''] = 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 }, + + -- If you prefer more traditional completion keymaps, + -- you can uncomment the following lines + --[''] = cmp.mapping.confirm { select = true }, + --[''] = cmp.mapping.select_next_item(), + --[''] = cmp.mapping.select_prev_item(), + + -- 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) + -- $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() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, + } + end, + }, + + { -- You can easily change to a different colorscheme. + -- Change the name of the colorscheme plugin below, and then + -- change the command in the config to whatever the name of that colorscheme is. + -- + -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + 'folke/tokyonight.nvim', + priority = 1000, -- Make sure to load this before all the other start plugins. + init = function() + -- Load the colorscheme here. + -- Like many other themes, this one has different styles, and you could load + -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. + vim.cmd.colorscheme 'tokyonight-night' + + -- You can configure highlights by doing something like: + vim.cmd.hi 'Comment gui=none' + end, + }, + + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + + { -- Collection of various small independent plugins/modules + 'echasnovski/mini.nvim', + config = function() + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - 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. + -- You could remove this setup call if you don't like it, + -- and try some other statusline plugin + local statusline = require 'mini.statusline' + -- set use_icons to true if you have a Nerd Font + statusline.setup { use_icons = vim.g.have_nerd_font } + + -- You can configure sections in the statusline by overriding their + -- default behavior. For example, here we set the section for + -- cursor location to LINE:COLUMN + ---@diagnostic disable-next-line: duplicate-set-field + statusline.section_location = function() + return '%2l:%-2v' + end + + -- ... and there is more! + -- Check out: https://github.com/echasnovski/mini.nvim + end, + }, + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + opts = { + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { + enable = true, + -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + -- If you are experiencing weird indenting issues, add the language to + -- the list of additional_vim_regex_highlighting and disabled languages for indent. + additional_vim_regex_highlighting = { 'ruby' }, + }, + indent = { enable = true, disable = { 'ruby' } }, + }, + config = function(_, opts) + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + + -- Prefer git instead of curl in order to improve connectivity in some environments + require('nvim-treesitter.install').prefer_git = true + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup(opts) + + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + end, + }, + + -- 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 + -- place them in the correct locations. + + -- 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', + -- require 'kickstart.plugins.lint', + -- require 'kickstart.plugins.autopairs', + -- require 'kickstart.plugins.neo-tree', + -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- This is the easiest way to modularize your config. + -- + -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. + -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` + { import = 'custom.plugins' }, +}, { + ui = { + -- If you are using a Nerd Font: set icons to an empty table which will use the + -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table + icons = vim.g.have_nerd_font and {} or { + cmd = '⌘', + config = '🛠', + event = '📅', + ft = '📂', + init = '⚙', + keys = '🗝', + plugin = '🔌', + runtime = '💻', + require = '🌙', + source = '📄', + start = '🚀', + task = '📌', + lazy = '💤 ', + }, + }, +}) diff --git a/set.lua b/set.lua new file mode 100644 index 00000000000..628799a1252 --- /dev/null +++ b/set.lua @@ -0,0 +1,79 @@ +-- [[ Setting options ]] +-- See `:help vim.opt` +-- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` + +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.termguicolors = true + +vim.opt.updatetime = 750 + +vim.opt.colorcolumn = '100' + +vim.g.have_nerd_font = false + +vim.opt.hlsearch = true + +-- 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 the 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'` +vim.opt.clipboard = 'unnamedplus' + +-- Enable break indent +vim.opt.breakindent = true +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true + +-- Save undo history +vim.opt.wrap = false +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir' +vim.opt.undofile = true + +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Keep signcolumn on by default +vim.opt.signcolumn = 'yes' + +-- Decrease update time +vim.opt.updatetime = 250 + +-- Decrease mapped sequence wait time +-- Displays which-key popup sooner +vim.opt.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + +-- 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 From 2a01bc8d323d3e977c869a7361c142832a281772 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 10:35:34 +0200 Subject: [PATCH 05/37] add many useful remaps --- keymaps.lua | 28 ++++++++++++++++++++++++++++ lua/custom/plugins/harpoon.lua | 8 ++++---- set.lua | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/keymaps.lua b/keymaps.lua index ca7abcca2d2..f1d46a8a11f 100644 --- a/keymaps.lua +++ b/keymaps.lua @@ -28,3 +28,31 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the left wind 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' }) + +-- Enable moving highlighted lines +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") + +-- Open file tree +vim.keymap.set('n', 'pv', vim.cmd.Ex) + +-- Keep cursor in place when appending next line +vim.keymap.set('n', 'J', 'mzJ`z') + +-- Keep highlighted search term in the center of the screen +vim.keymap.set('n', 'n', 'nzzzv') +vim.keymap.set('n', 'N', 'Nzzzv') + +-- Replace highlighted text with yanked one +vim.keymap.set('x', 'p', '"_dP') + +-- Make sure yanking works with d +vim.keymap.set('n', 'd', '"_d') +vim.keymap.set('v', 'd', '"_d') + +vim.keymap.set('n', '', 'cnextzz') +vim.keymap.set('n', '', 'cprevzz') +vim.keymap.set('n', 'k', 'lnextzz') +vim.keymap.set('n', 'j', 'lprevzz') + +vim.keymap.set('n', 'g', [[:%s/\<\>//gI]]) diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua index f4aa12ca2e1..41fa0b717db 100644 --- a/lua/custom/plugins/harpoon.lua +++ b/lua/custom/plugins/harpoon.lua @@ -33,16 +33,16 @@ return { vim.keymap.set('n', 'a', function() harpoon:list():add() end) - vim.keymap.set('n', '', function() + vim.keymap.set('n', '1', function() harpoon:list():select(1) end) - vim.keymap.set('n', '', function() + vim.keymap.set('n', '2', function() harpoon:list():select(2) end) - vim.keymap.set('n', '', function() + vim.keymap.set('n', '3', function() harpoon:list():select(3) end) - vim.keymap.set('n', '', function() + vim.keymap.set('n', '4', function() harpoon:list():select(4) end) diff --git a/set.lua b/set.lua index 628799a1252..7942d1aa87e 100644 --- a/set.lua +++ b/set.lua @@ -11,7 +11,7 @@ vim.opt.relativenumber = true vim.opt.termguicolors = true -vim.opt.updatetime = 750 +vim.opt.updatetime = 50 vim.opt.colorcolumn = '100' From 38857a2ccba754b53a3f5c96ebaba97a13c7b05f Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 10:36:20 +0200 Subject: [PATCH 06/37] rename keymaps.lua --- init.lua | 2 +- keymaps.lua => remap.lua | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename keymaps.lua => remap.lua (100%) diff --git a/init.lua b/init.lua index e0a7d802e7c..ffd936ceb87 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ require 'set' -require 'keymaps' +require 'remap' require 'autocommands' require 'plugins' diff --git a/keymaps.lua b/remap.lua similarity index 100% rename from keymaps.lua rename to remap.lua From a9c63d770fca115bd3b63fa1dcd9e598cc978aa2 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 11:18:35 +0200 Subject: [PATCH 07/37] move scripts to correct folder --- autocommands.lua => lua/autocommands.lua | 0 plugins.lua => lua/plugins.lua | 0 remap.lua => lua/remap.lua | 0 set.lua => lua/set.lua | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename autocommands.lua => lua/autocommands.lua (100%) rename plugins.lua => lua/plugins.lua (100%) rename remap.lua => lua/remap.lua (100%) rename set.lua => lua/set.lua (100%) diff --git a/autocommands.lua b/lua/autocommands.lua similarity index 100% rename from autocommands.lua rename to lua/autocommands.lua diff --git a/plugins.lua b/lua/plugins.lua similarity index 100% rename from plugins.lua rename to lua/plugins.lua diff --git a/remap.lua b/lua/remap.lua similarity index 100% rename from remap.lua rename to lua/remap.lua diff --git a/set.lua b/lua/set.lua similarity index 100% rename from set.lua rename to lua/set.lua From 869a8cd6730711ec1c37041e9b7282b6e6279f9c Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 14:54:34 +0200 Subject: [PATCH 08/37] add dotnet support and remove deprecated remap --- lua/plugins.lua | 2 ++ lua/remap.lua | 6 ++++-- lua/set.lua | 10 ++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index c4904702504..b144fac859e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -370,6 +370,8 @@ require('lazy').setup({ -- -- But for many setups, the LSP (`tsserver`) will work just fine tsserver = {}, + csharp_ls = {}, + netcoredbg = {}, -- lua_ls = { diff --git a/lua/remap.lua b/lua/remap.lua index f1d46a8a11f..88dc76ac556 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -1,12 +1,14 @@ -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +vim.keymap.set('i', 'jj', '') + -- clear higlight on search on pressing in normal mode 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', '[d', vim.diagnostic.jump, { count = -1, desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.jump, { count = 1, desc = 'Go to next [D]iagnostic message' }) 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' }) diff --git a/lua/set.lua b/lua/set.lua index 7942d1aa87e..73740608056 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -11,8 +11,6 @@ vim.opt.relativenumber = true vim.opt.termguicolors = true -vim.opt.updatetime = 50 - vim.opt.colorcolumn = '100' vim.g.have_nerd_font = false @@ -32,9 +30,9 @@ vim.opt.clipboard = 'unnamedplus' -- Enable break indent vim.opt.breakindent = true -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.shiftwidth = 4 +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.shiftwidth = 2 vim.opt.expandtab = true vim.opt.smartindent = true @@ -53,7 +51,7 @@ vim.opt.smartcase = true vim.opt.signcolumn = 'yes' -- Decrease update time -vim.opt.updatetime = 250 +vim.opt.updatetime = 50 -- Decrease mapped sequence wait time -- Displays which-key popup sooner From ceee1003cc0b6032ec84b0cf70430fa80c277b6a Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 14:59:33 +0200 Subject: [PATCH 09/37] fix syntax error --- lua/remap.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/remap.lua b/lua/remap.lua index 88dc76ac556..77a98f34e32 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -7,8 +7,12 @@ vim.keymap.set('i', 'jj', '') vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.jump, { count = -1, desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.jump, { count = 1, desc = 'Go to next [D]iagnostic message' }) +vim.keymap.set('n', '[d', function() + vim.diagnostic.jump { count = -1 } +end, { desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', function() + vim.diagnostic.jump { count = -1 } +end, { desc = 'Go to next [D]iagnostic message' }) 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' }) From 8c8f8b016ce72dc1831aa267f928de0dd5550d78 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 15:05:45 +0200 Subject: [PATCH 10/37] adjust key bindings --- lua/custom/plugins/harpoon.lua | 8 ++++---- lua/remap.lua | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua index 41fa0b717db..88956d13442 100644 --- a/lua/custom/plugins/harpoon.lua +++ b/lua/custom/plugins/harpoon.lua @@ -33,16 +33,16 @@ return { vim.keymap.set('n', 'a', function() harpoon:list():add() end) - vim.keymap.set('n', '1', function() + vim.keymap.set('n', '', function() harpoon:list():select(1) end) - vim.keymap.set('n', '2', function() + vim.keymap.set('n', '', function() harpoon:list():select(2) end) - vim.keymap.set('n', '3', function() + vim.keymap.set('n', '', function() harpoon:list():select(3) end) - vim.keymap.set('n', '4', function() + vim.keymap.set('n', '', function() harpoon:list():select(4) end) diff --git a/lua/remap.lua b/lua/remap.lua index 77a98f34e32..0ba1bf50c72 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -27,13 +27,12 @@ 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' }) +-- THIS WOULD CLASH WITH HARPOON BUFFER SELECTION +-- 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' }) -- Enable moving highlighted lines vim.keymap.set('v', 'J', ":m '>+1gv=gv") From c97a7a128495693813b21d8323db5ba7cf2dc04b Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 6 Jun 2024 16:40:06 +0200 Subject: [PATCH 11/37] add undotree --- lua/custom/plugins/undotree.lua | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lua/custom/plugins/undotree.lua diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua new file mode 100644 index 00000000000..cf4f5a1e508 --- /dev/null +++ b/lua/custom/plugins/undotree.lua @@ -0,0 +1,8 @@ +return { + 'jiaoshijie/undotree', + dependencies = 'nvim-lua/plenary.nvim', + config = true, + keys = { -- load the plugin only when using it's keybinding: + { 'u', "lua require('undotree').toggle()" }, + }, +} From e934fef8f1d5c4e833192230ba5fd37909b321ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren?= Date: Fri, 7 Jun 2024 09:50:15 +0200 Subject: [PATCH 12/37] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f445b65ecd5..15e94dc1cfe 100644 --- a/README.md +++ b/README.md @@ -60,14 +60,10 @@ fork to your machine using one of the commands below, depending on your OS. > `https://github.com//kickstart.nvim.git` #### Clone kickstart.nvim -> **NOTE** -> If following the recommended step above (i.e., forking the repo), replace -> `nvim-lua` with `` in the commands below -
Linux and Mac ```sh -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim +git clone https://github.com/TheSoeren/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim ```
@@ -77,13 +73,13 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO If you're using `cmd.exe`: ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ +git clone https://github.com/TheSoeren/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ ``` If you're using `powershell.exe` ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ +git clone https://github.com/TheSoeren/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ ``` From dd28b344e4689f7003635b264c4517f15f89122f Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Tue, 18 Jun 2024 17:23:31 +0200 Subject: [PATCH 13/37] add cpp lsp --- lua/kickstart/plugins/debug.lua | 2 ++ lua/plugins.lua | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 31dfecf5b38..9a185846c61 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -42,6 +42,8 @@ return { ensure_installed = { -- Update this to ensure that you have the debuggers for the langs you want 'delve', + 'netcoredbg', + 'codelldb', }, } diff --git a/lua/plugins.lua b/lua/plugins.lua index b144fac859e..a7c60b4189c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -372,6 +372,7 @@ require('lazy').setup({ tsserver = {}, csharp_ls = {}, netcoredbg = {}, + clangd = {}, -- lua_ls = { @@ -403,6 +404,12 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'clangd', + 'clang-format', + 'csharp_ls', + 'lua_ls', + 'omnisharp', + 'tsserver', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } From e2f3ffcc02321f5224b6472add79a693fd88ff3f Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Tue, 25 Jun 2024 22:34:00 +0200 Subject: [PATCH 14/37] Generic changes, notably adding git-blame --- README.md | 4 ++-- lua/custom/plugins/csharpls-extended-lsp.lua | 1 + lua/custom/plugins/git-blame.lua | 9 +++++++++ lua/custom/plugins/harpoon.lua | 16 +++++++++++----- lua/plugins.lua | 20 +------------------- lua/remap.lua | 8 -------- 6 files changed, 24 insertions(+), 34 deletions(-) create mode 100644 lua/custom/plugins/csharpls-extended-lsp.lua create mode 100644 lua/custom/plugins/git-blame.lua diff --git a/README.md b/README.md index 15e94dc1cfe..f988688b73b 100644 --- a/README.md +++ b/README.md @@ -131,8 +131,8 @@ examples of adding popularly requested plugins. same functionality is available here: * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) * Discussions on this topic can be found here: - * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) - * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) + * [Restructure the configuration](https://github.com/TheSoeren/kickstart.nvim/issues/218) + * [Reorganize init.lua into a multi-file setup](https://github.com/TheSoeren/kickstart.nvim/pull/473) ### Install Recipes diff --git a/lua/custom/plugins/csharpls-extended-lsp.lua b/lua/custom/plugins/csharpls-extended-lsp.lua new file mode 100644 index 00000000000..f0cc03ab8dc --- /dev/null +++ b/lua/custom/plugins/csharpls-extended-lsp.lua @@ -0,0 +1 @@ +return { 'Decodetalkers/csharpls-extended-lsp.nvim' } diff --git a/lua/custom/plugins/git-blame.lua b/lua/custom/plugins/git-blame.lua new file mode 100644 index 00000000000..fbc9867e952 --- /dev/null +++ b/lua/custom/plugins/git-blame.lua @@ -0,0 +1,9 @@ +return { + 'FabijanZulj/blame.nvim', + config = function() + local blame = require 'blame' + blame.setup() + + vim.keymap.set('n', 'gb', ':BlameToggle') + end, +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua index 88956d13442..54ef1559d6a 100644 --- a/lua/custom/plugins/harpoon.lua +++ b/lua/custom/plugins/harpoon.lua @@ -33,6 +33,7 @@ return { vim.keymap.set('n', 'a', function() harpoon:list():add() end) + vim.keymap.set('n', '', function() harpoon:list():select(1) end) @@ -46,12 +47,17 @@ return { harpoon:list():select(4) end) - -- Toggle previous & next buffers stored within Harpoon list - vim.keymap.set('n', '', function() - harpoon:list():prev() + vim.keymap.set('n', '', function() + harpoon:list():replace_at(1) + end) + vim.keymap.set('n', '', function() + harpoon:list():replace_at(2) + end) + vim.keymap.set('n', '', function() + harpoon:list():replace_at(3) end) - vim.keymap.set('n', '', function() - harpoon:list():next() + vim.keymap.set('n', '', function() + harpoon:list():replace_at(4) end) end, } diff --git a/lua/plugins.lua b/lua/plugins.lua index a7c60b4189c..0035bb1d773 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -359,16 +359,6 @@ require('lazy').setup({ -- - 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 = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine tsserver = {}, csharp_ls = {}, netcoredbg = {}, @@ -404,12 +394,9 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code - 'clangd', 'clang-format', - 'csharp_ls', 'lua_ls', 'omnisharp', - 'tsserver', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -447,7 +434,7 @@ require('lazy').setup({ -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } + local disable_filetypes = { c = true } return { timeout_ms = 500, lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], @@ -683,11 +670,6 @@ require('lazy').setup({ -- require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` - -- This is the easiest way to modularize your config. - -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` { import = 'custom.plugins' }, }, { ui = { diff --git a/lua/remap.lua b/lua/remap.lua index 0ba1bf50c72..137d98350d0 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -26,14 +26,6 @@ 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. --- See `:help wincmd` for a list of all window commands --- THIS WOULD CLASH WITH HARPOON BUFFER SELECTION --- 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' }) - -- Enable moving highlighted lines vim.keymap.set('v', 'J', ":m '>+1gv=gv") vim.keymap.set('v', 'K', ":m '<-2gv=gv") From 7c958943130468ad7e51c1a5241fbb5fdd29c147 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Tue, 25 Jun 2024 22:35:43 +0200 Subject: [PATCH 15/37] remove clashing key binds --- lua/remap.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/remap.lua b/lua/remap.lua index 137d98350d0..18afc4d480f 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -47,8 +47,6 @@ vim.keymap.set('x', 'p', '"_dP') vim.keymap.set('n', 'd', '"_d') vim.keymap.set('v', 'd', '"_d') -vim.keymap.set('n', '', 'cnextzz') -vim.keymap.set('n', '', 'cprevzz') vim.keymap.set('n', 'k', 'lnextzz') vim.keymap.set('n', 'j', 'lprevzz') From 3f859fa83cae8e531cf105277aa218c24ef152a9 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Sat, 29 Jun 2024 19:49:14 +0200 Subject: [PATCH 16/37] add java lsp and cmake plugin --- ftplugin/java.lua | 271 +++++++++++++++++++++++++++++ lua/custom/plugins/cmake-tools.lua | 6 + lua/custom/plugins/nvim-jdtls.lua | 1 + lua/kickstart/plugins/debug.lua | 2 + lua/plugins.lua | 39 +++++ lua/remap.lua | 6 - 6 files changed, 319 insertions(+), 6 deletions(-) create mode 100644 ftplugin/java.lua create mode 100644 lua/custom/plugins/cmake-tools.lua create mode 100644 lua/custom/plugins/nvim-jdtls.lua diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 00000000000..0e7ef28b44f --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,271 @@ +local java_cmds = vim.api.nvim_create_augroup('java_cmds', { clear = true }) +local cache_vars = {} + +-- Here you can add files/folders that you use at +-- the root of your project. `nvim-jdtls` will use +-- these to find the path to your project source code. +local root_files = { + '.git', + + --- here are more examples files that may or + --- may not work as root files, according to some guy on the internet + -- 'mvnw', + -- 'gradlew', + -- 'pom.xml', + -- 'build.gradle', +} + +local features = { + -- change this to `true` to enable codelens + codelens = false, + + -- change this to `true` if you have `nvim-dap`, + -- `java-test` and `java-debug-adapter` installed + debugger = false, +} + +local function get_jdtls_paths() + if cache_vars.paths then + return cache_vars.paths + end + + local path = {} + + path.data_dir = vim.fn.stdpath 'cache' .. '/nvim-jdtls' + + local jdtls_install = require('mason-registry').get_package('jdtls'):get_install_path() + + path.java_agent = jdtls_install .. '/lombok.jar' + path.launcher_jar = vim.fn.glob(jdtls_install .. '/plugins/org.eclipse.equinox.launcher_*.jar') + + if vim.fn.has 'mac' == 1 then + path.platform_config = jdtls_install .. '/config_mac' + elseif vim.fn.has 'unix' == 1 then + path.platform_config = jdtls_install .. '/config_linux' + elseif vim.fn.has 'win32' == 1 then + path.platform_config = jdtls_install .. '/config_win' + end + + path.bundles = {} + + --- + -- Include java-test bundle if present + --- + local java_test_path = require('mason-registry').get_package('java-test'):get_install_path() + + local java_test_bundle = vim.split(vim.fn.glob(java_test_path .. '/extension/server/*.jar'), '\n') + + if java_test_bundle[1] ~= '' then + vim.list_extend(path.bundles, java_test_bundle) + end + + --- + -- Include java-debug-adapter bundle if present + --- + local java_debug_path = require('mason-registry').get_package('java-debug-adapter'):get_install_path() + + local java_debug_bundle = vim.split(vim.fn.glob(java_debug_path .. '/extension/server/com.microsoft.java.debug.plugin-*.jar'), '\n') + + if java_debug_bundle[1] ~= '' then + vim.list_extend(path.bundles, java_debug_bundle) + end + + --- + -- Useful if you're starting jdtls with a Java version that's + -- different from the one the project uses. + --- + path.runtimes = { + -- Note: the field `name` must be a valid `ExecutionEnvironment`, + -- you can find the list here: + -- https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request + { + name = 'JavaSE-21', + path = vim.fn.expand '~/.sdkman/candidates/java/21.0.1-amzn', + }, + } + + cache_vars.paths = path + + return path +end + +local function enable_codelens(bufnr) + pcall(vim.lsp.codelens.refresh) + + vim.api.nvim_create_autocmd('BufWritePost', { + buffer = bufnr, + group = java_cmds, + desc = 'refresh codelens', + callback = function() + pcall(vim.lsp.codelens.refresh) + end, + }) +end + +local function enable_debugger(bufnr) + require('jdtls').setup_dap { hotcodereplace = 'auto' } + require('jdtls.dap').setup_dap_main_class_configs() + + local opts = { buffer = bufnr } + vim.keymap.set('n', 'df', "lua require('jdtls').test_class()", opts) + vim.keymap.set('n', 'dn', "lua require('jdtls').test_nearest_method()", opts) +end + +local function jdtls_on_attach(client, bufnr) + if features.debugger then + enable_debugger(bufnr) + end + + if features.codelens then + enable_codelens(bufnr) + end + + -- The following mappings are based on the suggested usage of nvim-jdtls + -- https://github.com/mfussenegger/nvim-jdtls#usage + + local opts = { buffer = bufnr } + vim.keymap.set('n', '', "lua require('jdtls').organize_imports()", opts) + vim.keymap.set('n', 'crv', "lua require('jdtls').extract_variable()", opts) + vim.keymap.set('x', 'crv', "lua require('jdtls').extract_variable(true)", opts) + vim.keymap.set('n', 'crc', "lua require('jdtls').extract_constant()", opts) + vim.keymap.set('x', 'crc', "lua require('jdtls').extract_constant(true)", opts) + vim.keymap.set('x', 'crm', "lua require('jdtls').extract_method(true)", opts) +end + +local function jdtls_setup(event) + local jdtls = require 'jdtls' + + local path = get_jdtls_paths() + local data_dir = path.data_dir .. '/' .. vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') + + if cache_vars.capabilities == nil then + jdtls.extendedClientCapabilities.resolveAdditionalTextEditsSupport = true + + local ok_cmp, cmp_lsp = pcall(require, 'cmp_nvim_lsp') + cache_vars.capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), ok_cmp and cmp_lsp.default_capabilities() or {}) + end + + -- The command that starts the language server + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + local cmd = { + -- 💀 + 'java', + + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultStartLevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Dlog.level=ALL', + '-javaagent:' .. path.java_agent, + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + + -- 💀 + '-jar', + path.launcher_jar, + + -- 💀 + '-configuration', + path.platform_config, + + -- 💀 + '-data', + data_dir, + } + + local home = os.getenv 'HOME' + local lsp_settings = { + java = { + -- jdt = { + -- ls = { + -- vmargs = "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m" + -- } + -- }, + eclipse = { + downloadSources = true, + }, + configuration = { + updateBuildConfiguration = 'interactive', + runtimes = path.runtimes, + }, + maven = { + downloadSources = true, + }, + implementationsCodeLens = { + enabled = true, + }, + referencesCodeLens = { + enabled = true, + }, + -- inlayHints = { + -- parameterNames = { + -- enabled = 'all' -- literals, all, none + -- } + -- }, + format = { + enabled = true, + settings = { + url = home .. '/.config/nvim/clavisit-eclipse-code-formatter.xml', + profile = 'ClavisJavaStyle', + }, + }, + }, + signatureHelp = { + enabled = true, + }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'org.junit.jupiter.api.Assertions.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + }, + }, + contentProvider = { + preferred = 'fernflower', + }, + extendedClientCapabilities = jdtls.extendedClientCapabilities, + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + codeGeneration = { + toString = { + template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}', + }, + useBlocks = true, + }, + } + + -- This starts a new client & server, + -- or attaches to an existing client & server depending on the `root_dir`. + jdtls.start_or_attach { + cmd = cmd, + settings = lsp_settings, + on_attach = jdtls_on_attach, + capabilities = cache_vars.capabilities, + root_dir = jdtls.setup.find_root(root_files), + flags = { + allow_incremental_sync = true, + }, + init_options = { + bundles = path.bundles, + }, + } +end + +vim.api.nvim_create_autocmd('FileType', { + group = java_cmds, + pattern = { 'java' }, + desc = 'Setup jdtls', + callback = jdtls_setup, +}) diff --git a/lua/custom/plugins/cmake-tools.lua b/lua/custom/plugins/cmake-tools.lua new file mode 100644 index 00000000000..7964cf7c7e1 --- /dev/null +++ b/lua/custom/plugins/cmake-tools.lua @@ -0,0 +1,6 @@ +return { + 'Civitasv/cmake-tools.nvim', + config = function() + require('cmake-tools').setup {} + end, +} diff --git a/lua/custom/plugins/nvim-jdtls.lua b/lua/custom/plugins/nvim-jdtls.lua new file mode 100644 index 00000000000..4ea3df01dae --- /dev/null +++ b/lua/custom/plugins/nvim-jdtls.lua @@ -0,0 +1 @@ +return { 'mfussenegger/nvim-jdtls' } diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 9a185846c61..4b93c42cd1d 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -44,6 +44,8 @@ return { 'delve', 'netcoredbg', 'codelldb', + 'java-debug-adapter', + 'java-test', }, } diff --git a/lua/plugins.lua b/lua/plugins.lua index 0035bb1d773..e95df6b8ec7 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -360,6 +360,38 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { tsserver = {}, + stylelint_lsp = { + filetypes = { 'css', 'scss' }, + root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), + settings = { + stylelintplus = { + autoFixOnFormat = true, + autoFixOnSave = true, + }, + }, + on_attach = function(client) + client.server_capabilities.document_formatting = false + end, + }, + eslint = { + bin = 'eslint', -- or `eslint_d` + code_actions = { + enable = true, + apply_on_save = { + enable = true, + types = { 'directive', 'problem', 'suggestion', 'layout' }, + }, + disable_rule_comment = { + enable = true, + location = 'separate_line', -- or `same_line` + }, + }, + diagnostics = { + enable = true, + report_unused_disable_directives = false, + run_on = 'type', -- or `save` + }, + }, csharp_ls = {}, netcoredbg = {}, clangd = {}, @@ -394,9 +426,12 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'eslint_d', + 'stylelint', 'clang-format', 'lua_ls', 'omnisharp', + 'jdtls', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -442,6 +477,10 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + typescript = { 'prettier' }, + javascript = { 'prettier' }, + json = { 'prettier' }, + html = { 'prettier' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lua/remap.lua b/lua/remap.lua index 18afc4d480f..713636a1448 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -20,12 +20,6 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) --- 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!!"') - -- Enable moving highlighted lines vim.keymap.set('v', 'J', ":m '>+1gv=gv") vim.keymap.set('v', 'K', ":m '<-2gv=gv") From 6171b6b70426c11a02f66d17a4dcd81784acd62f Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Sun, 30 Jun 2024 14:30:13 +0200 Subject: [PATCH 17/37] added prettier to autoinstall --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index e95df6b8ec7..b7ece7d8bac 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -432,6 +432,7 @@ require('lazy').setup({ 'lua_ls', 'omnisharp', 'jdtls', + 'prettier', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } From 7123bf8ae69230be50a09d104ccb81e4d5d1d7be Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Sun, 28 Jul 2024 11:33:46 +0200 Subject: [PATCH 18/37] fix java and cleanup --- doc/kickstart.txt | 24 --- doc/tags | 3 - ftplugin/java.lua | 271 ------------------------- lua/custom/plugins/comment.lua | 2 + lua/custom/plugins/gitsigns.lua | 12 ++ lua/custom/plugins/nvim-jdtls.lua | 1 - lua/custom/plugins/telescope.lua | 85 ++++++++ lua/custom/plugins/todo-comments.lua | 1 + lua/custom/plugins/which-key.lua | 29 +++ lua/kickstart/plugins/debug.lua | 58 +++--- lua/plugins.lua | 282 +++------------------------ 11 files changed, 180 insertions(+), 588 deletions(-) delete mode 100644 doc/kickstart.txt delete mode 100644 doc/tags delete mode 100644 ftplugin/java.lua create mode 100644 lua/custom/plugins/comment.lua create mode 100644 lua/custom/plugins/gitsigns.lua delete mode 100644 lua/custom/plugins/nvim-jdtls.lua create mode 100644 lua/custom/plugins/telescope.lua create mode 100644 lua/custom/plugins/todo-comments.lua create mode 100644 lua/custom/plugins/which-key.lua diff --git a/doc/kickstart.txt b/doc/kickstart.txt deleted file mode 100644 index cb87ac3f1de..00000000000 --- a/doc/kickstart.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================================ -INTRODUCTION *kickstart.nvim* - -Kickstart.nvim is a project to help you get started on your neovim journey. - - *kickstart-is-not* -It is not: -- Complete framework for every plugin under the sun -- Place to add every plugin that could ever be useful - - *kickstart-is* -It is: -- Somewhere that has a good start for the most common "IDE" type features: - - autocompletion - - goto-definition - - find references - - fuzzy finding - - and hinting at what more can be done :) -- A place to _kickstart_ your journey. - - You should fork this project and use/modify it so that it matches your - style and preferences. If you don't want to do that, there are probably - other projects that would fit much better for you (and that's great!)! - - vim:tw=78:ts=8:ft=help:norl: diff --git a/doc/tags b/doc/tags deleted file mode 100644 index 687ae7721d9..00000000000 --- a/doc/tags +++ /dev/null @@ -1,3 +0,0 @@ -kickstart-is kickstart.txt /*kickstart-is* -kickstart-is-not kickstart.txt /*kickstart-is-not* -kickstart.nvim kickstart.txt /*kickstart.nvim* diff --git a/ftplugin/java.lua b/ftplugin/java.lua deleted file mode 100644 index 0e7ef28b44f..00000000000 --- a/ftplugin/java.lua +++ /dev/null @@ -1,271 +0,0 @@ -local java_cmds = vim.api.nvim_create_augroup('java_cmds', { clear = true }) -local cache_vars = {} - --- Here you can add files/folders that you use at --- the root of your project. `nvim-jdtls` will use --- these to find the path to your project source code. -local root_files = { - '.git', - - --- here are more examples files that may or - --- may not work as root files, according to some guy on the internet - -- 'mvnw', - -- 'gradlew', - -- 'pom.xml', - -- 'build.gradle', -} - -local features = { - -- change this to `true` to enable codelens - codelens = false, - - -- change this to `true` if you have `nvim-dap`, - -- `java-test` and `java-debug-adapter` installed - debugger = false, -} - -local function get_jdtls_paths() - if cache_vars.paths then - return cache_vars.paths - end - - local path = {} - - path.data_dir = vim.fn.stdpath 'cache' .. '/nvim-jdtls' - - local jdtls_install = require('mason-registry').get_package('jdtls'):get_install_path() - - path.java_agent = jdtls_install .. '/lombok.jar' - path.launcher_jar = vim.fn.glob(jdtls_install .. '/plugins/org.eclipse.equinox.launcher_*.jar') - - if vim.fn.has 'mac' == 1 then - path.platform_config = jdtls_install .. '/config_mac' - elseif vim.fn.has 'unix' == 1 then - path.platform_config = jdtls_install .. '/config_linux' - elseif vim.fn.has 'win32' == 1 then - path.platform_config = jdtls_install .. '/config_win' - end - - path.bundles = {} - - --- - -- Include java-test bundle if present - --- - local java_test_path = require('mason-registry').get_package('java-test'):get_install_path() - - local java_test_bundle = vim.split(vim.fn.glob(java_test_path .. '/extension/server/*.jar'), '\n') - - if java_test_bundle[1] ~= '' then - vim.list_extend(path.bundles, java_test_bundle) - end - - --- - -- Include java-debug-adapter bundle if present - --- - local java_debug_path = require('mason-registry').get_package('java-debug-adapter'):get_install_path() - - local java_debug_bundle = vim.split(vim.fn.glob(java_debug_path .. '/extension/server/com.microsoft.java.debug.plugin-*.jar'), '\n') - - if java_debug_bundle[1] ~= '' then - vim.list_extend(path.bundles, java_debug_bundle) - end - - --- - -- Useful if you're starting jdtls with a Java version that's - -- different from the one the project uses. - --- - path.runtimes = { - -- Note: the field `name` must be a valid `ExecutionEnvironment`, - -- you can find the list here: - -- https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request - { - name = 'JavaSE-21', - path = vim.fn.expand '~/.sdkman/candidates/java/21.0.1-amzn', - }, - } - - cache_vars.paths = path - - return path -end - -local function enable_codelens(bufnr) - pcall(vim.lsp.codelens.refresh) - - vim.api.nvim_create_autocmd('BufWritePost', { - buffer = bufnr, - group = java_cmds, - desc = 'refresh codelens', - callback = function() - pcall(vim.lsp.codelens.refresh) - end, - }) -end - -local function enable_debugger(bufnr) - require('jdtls').setup_dap { hotcodereplace = 'auto' } - require('jdtls.dap').setup_dap_main_class_configs() - - local opts = { buffer = bufnr } - vim.keymap.set('n', 'df', "lua require('jdtls').test_class()", opts) - vim.keymap.set('n', 'dn', "lua require('jdtls').test_nearest_method()", opts) -end - -local function jdtls_on_attach(client, bufnr) - if features.debugger then - enable_debugger(bufnr) - end - - if features.codelens then - enable_codelens(bufnr) - end - - -- The following mappings are based on the suggested usage of nvim-jdtls - -- https://github.com/mfussenegger/nvim-jdtls#usage - - local opts = { buffer = bufnr } - vim.keymap.set('n', '', "lua require('jdtls').organize_imports()", opts) - vim.keymap.set('n', 'crv', "lua require('jdtls').extract_variable()", opts) - vim.keymap.set('x', 'crv', "lua require('jdtls').extract_variable(true)", opts) - vim.keymap.set('n', 'crc', "lua require('jdtls').extract_constant()", opts) - vim.keymap.set('x', 'crc', "lua require('jdtls').extract_constant(true)", opts) - vim.keymap.set('x', 'crm', "lua require('jdtls').extract_method(true)", opts) -end - -local function jdtls_setup(event) - local jdtls = require 'jdtls' - - local path = get_jdtls_paths() - local data_dir = path.data_dir .. '/' .. vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') - - if cache_vars.capabilities == nil then - jdtls.extendedClientCapabilities.resolveAdditionalTextEditsSupport = true - - local ok_cmp, cmp_lsp = pcall(require, 'cmp_nvim_lsp') - cache_vars.capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), ok_cmp and cmp_lsp.default_capabilities() or {}) - end - - -- The command that starts the language server - -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line - local cmd = { - -- 💀 - 'java', - - '-Declipse.application=org.eclipse.jdt.ls.core.id1', - '-Dosgi.bundles.defaultStartLevel=4', - '-Declipse.product=org.eclipse.jdt.ls.core.product', - '-Dlog.protocol=true', - '-Dlog.level=ALL', - '-javaagent:' .. path.java_agent, - '-Xms1g', - '--add-modules=ALL-SYSTEM', - '--add-opens', - 'java.base/java.util=ALL-UNNAMED', - '--add-opens', - 'java.base/java.lang=ALL-UNNAMED', - - -- 💀 - '-jar', - path.launcher_jar, - - -- 💀 - '-configuration', - path.platform_config, - - -- 💀 - '-data', - data_dir, - } - - local home = os.getenv 'HOME' - local lsp_settings = { - java = { - -- jdt = { - -- ls = { - -- vmargs = "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m" - -- } - -- }, - eclipse = { - downloadSources = true, - }, - configuration = { - updateBuildConfiguration = 'interactive', - runtimes = path.runtimes, - }, - maven = { - downloadSources = true, - }, - implementationsCodeLens = { - enabled = true, - }, - referencesCodeLens = { - enabled = true, - }, - -- inlayHints = { - -- parameterNames = { - -- enabled = 'all' -- literals, all, none - -- } - -- }, - format = { - enabled = true, - settings = { - url = home .. '/.config/nvim/clavisit-eclipse-code-formatter.xml', - profile = 'ClavisJavaStyle', - }, - }, - }, - signatureHelp = { - enabled = true, - }, - completion = { - favoriteStaticMembers = { - 'org.hamcrest.MatcherAssert.assertThat', - 'org.hamcrest.Matchers.*', - 'org.hamcrest.CoreMatchers.*', - 'org.junit.jupiter.api.Assertions.*', - 'java.util.Objects.requireNonNull', - 'java.util.Objects.requireNonNullElse', - 'org.mockito.Mockito.*', - }, - }, - contentProvider = { - preferred = 'fernflower', - }, - extendedClientCapabilities = jdtls.extendedClientCapabilities, - sources = { - organizeImports = { - starThreshold = 9999, - staticStarThreshold = 9999, - }, - }, - codeGeneration = { - toString = { - template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}', - }, - useBlocks = true, - }, - } - - -- This starts a new client & server, - -- or attaches to an existing client & server depending on the `root_dir`. - jdtls.start_or_attach { - cmd = cmd, - settings = lsp_settings, - on_attach = jdtls_on_attach, - capabilities = cache_vars.capabilities, - root_dir = jdtls.setup.find_root(root_files), - flags = { - allow_incremental_sync = true, - }, - init_options = { - bundles = path.bundles, - }, - } -end - -vim.api.nvim_create_autocmd('FileType', { - group = java_cmds, - pattern = { 'java' }, - desc = 'Setup jdtls', - callback = jdtls_setup, -}) diff --git a/lua/custom/plugins/comment.lua b/lua/custom/plugins/comment.lua new file mode 100644 index 00000000000..b838291e8a8 --- /dev/null +++ b/lua/custom/plugins/comment.lua @@ -0,0 +1,2 @@ +-- "gc" to comment visual regions/lines +return { 'numToStr/Comment.nvim', opts = {} } diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua new file mode 100644 index 00000000000..4f5441c7f9a --- /dev/null +++ b/lua/custom/plugins/gitsigns.lua @@ -0,0 +1,12 @@ +return { -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, +} diff --git a/lua/custom/plugins/nvim-jdtls.lua b/lua/custom/plugins/nvim-jdtls.lua deleted file mode 100644 index 4ea3df01dae..00000000000 --- a/lua/custom/plugins/nvim-jdtls.lua +++ /dev/null @@ -1 +0,0 @@ -return { 'mfussenegger/nvim-jdtls' } diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 00000000000..27731994961 --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,85 @@ +return { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', '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', '', 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 the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', '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, +} diff --git a/lua/custom/plugins/todo-comments.lua b/lua/custom/plugins/todo-comments.lua new file mode 100644 index 00000000000..898f4669c6d --- /dev/null +++ b/lua/custom/plugins/todo-comments.lua @@ -0,0 +1 @@ +return { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } } diff --git a/lua/custom/plugins/which-key.lua b/lua/custom/plugins/which-key.lua new file mode 100644 index 00000000000..cce7e5edaec --- /dev/null +++ b/lua/custom/plugins/which-key.lua @@ -0,0 +1,29 @@ +return { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + config = function() -- This is the function that runs, AFTER loading + require('which-key').setup() + + -- Document existing key chains + require('which-key').add { + { 'c', group = '[C]ode' }, + { 'c_', hidden = true }, + { 'd', group = '[D]ocument' }, + { 'd_', hidden = true }, + { 'h', group = 'Git [H]unk' }, + { 'h_', hidden = true }, + { 'r', group = '[R]ename' }, + { 'r_', hidden = true }, + { 's', group = '[S]earch' }, + { 's_', hidden = true }, + { 't', group = '[T]oggle' }, + { 't_', hidden = true }, + { 'w', group = '[W]orkspace' }, + { 'w_', hidden = true }, + } + -- visual mode + require('which-key').add { + { 'h', desc = 'Git [H]unk', mode = 'v' }, + } + end, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 4b93c42cd1d..9b45e25152c 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -1,15 +1,5 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - return { - -- NOTE: Yes, you can install new plugins here! 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well dependencies = { -- Creates a beautiful debugger UI 'rcarriga/nvim-dap-ui', @@ -29,27 +19,16 @@ return { local dapui = require 'dapui' require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations automatic_installation = true, - -- You can provide additional configuration to the handlers, -- see mason-nvim-dap README for more information handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', 'netcoredbg', 'codelldb', - 'java-debug-adapter', - 'java-test', }, } - -- Basic debugging keymaps, feel free to change to your liking! vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) @@ -62,9 +41,31 @@ return { -- Dap UI setup -- For more information, see |:help nvim-dap-ui| dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. + layouts = { + { + -- You can change the order of elements in the sidebar + elements = { + -- Provide IDs as strings or tables with "id" and "size" keys + { + id = 'scopes', + size = 0.35, -- Can be float or integer > 1 + }, + { id = 'breakpoints', size = 0.25 }, + { id = 'stacks', size = 0.25 }, + { id = 'watches', size = 0.25 }, + }, + size = 40, + position = 'left', -- Can be "left" or "right" + }, + { + elements = { + 'repl', + 'console', + }, + size = 15, + position = 'bottom', -- Can be "bottom" or "top" + }, + }, icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, controls = { icons = { @@ -87,14 +88,5 @@ return { dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, - }, - } end, } diff --git a/lua/plugins.lua b/lua/plugins.lua index b7ece7d8bac..c260f0bd963 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,5 +1,3 @@ --- [[ 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 local lazyrepo = 'https://github.com/folke/lazy.nvim.git' @@ -7,260 +5,32 @@ if not vim.loop.fs_stat(lazypath) then end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. require('lazy').setup({ - -- NOTE: Plugins can be added 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 link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - -- 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 `gitsigns.nvim`. This is equivalent to the following Lua: - -- require('gitsigns').setup({ ... }) - -- - -- 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 = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, - - -- NOTE: Plugins can also be configured to run Lua code when they are loaded. - -- - -- This is often very useful to both group configuration, as well as handle - -- lazy loading plugins that don't need to be loaded immediately at startup. - -- - -- For example, in the following configuration, we use: - -- event = 'VimEnter' - -- - -- which loads which-key before all the UI elements are loaded. Events can be - -- normal autocommands events (`:help autocmd-events`). - -- - -- Then, because we use the `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 = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - 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' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, - } - -- visual mode - require('which-key').register({ - ['h'] = { 'Git [H]unk' }, - }, { mode = 'v' }) - 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 = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', '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', '', 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 the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', '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', dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants + { 'j-hui/fidget.nvim', opts = {} }, -- Useful status updates for LSP. 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + 'nvim-java/nvim-java', -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins -- used for completion, annotations and signatures of Neovim apis { 'folke/neodev.nvim', opts = {} }, }, config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. local map = function(keys, func, desc) vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- 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') @@ -349,9 +119,6 @@ require('lazy').setup({ 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. - -- -- 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 @@ -360,6 +127,7 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { tsserver = {}, + angularls = {}, stylelint_lsp = { filetypes = { 'css', 'scss' }, root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), @@ -434,11 +202,21 @@ require('lazy').setup({ 'jdtls', 'prettier', }) + + -- Skip automatic setup for servers + local skip_setup = { + 'jdtls', + } + require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { handlers = { function(server_name) + if vim.tbl_contains(skip_setup, server_name) then + return + end + local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling @@ -446,6 +224,15 @@ require('lazy').setup({ server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, + jdtls = function() + require('java').setup { + -- Your custom jdtls settings goes here + } + + require('lspconfig').jdtls.setup { + -- Your custom nvim-java configuration goes here + } + end, }, } end, @@ -481,7 +268,9 @@ require('lazy').setup({ typescript = { 'prettier' }, javascript = { 'prettier' }, json = { 'prettier' }, + scss = { 'prettier' }, html = { 'prettier' }, + -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -604,16 +393,9 @@ 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', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. vim.cmd.colorscheme 'tokyonight-night' -- You can configure highlights by doing something like: @@ -621,9 +403,6 @@ require('lazy').setup({ end, }, - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', config = function() @@ -665,7 +444,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c', 'java' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -694,16 +473,7 @@ 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 - -- place them in the correct locations. - - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart - -- - -- Here are some example plugins that I've included in the Kickstart repository. - -- Uncomment any of the lines below to enable them (you will need to restart nvim). - -- - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', From 9651e80d7e649012ef669ffa9122a3151aca831e Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Tue, 30 Jul 2024 21:41:27 +0200 Subject: [PATCH 19/37] resolve conflict --- lua/plugins.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index c260f0bd963..c0270ad662a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -163,6 +163,7 @@ require('lazy').setup({ csharp_ls = {}, netcoredbg = {}, clangd = {}, + marksman = {}, -- lua_ls = { @@ -270,7 +271,7 @@ require('lazy').setup({ json = { 'prettier' }, scss = { 'prettier' }, html = { 'prettier' }, - + markdown = { 'prettier' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- From e091cb27b7d391928cc9b7a8e0c1f30e552cb836 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Tue, 17 Sep 2024 10:42:30 +0200 Subject: [PATCH 20/37] updated neo-tree --- lua/custom/plugins/comment.lua | 38 +++++++++++++++++++++++++++++- lua/custom/plugins/ts-comment.lua | 1 + lua/kickstart/plugins/debug.lua | 4 ---- lua/kickstart/plugins/neo-tree.lua | 16 +++++++------ lua/plugins.lua | 10 +++++--- lua/remap.lua | 3 --- 6 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 lua/custom/plugins/ts-comment.lua diff --git a/lua/custom/plugins/comment.lua b/lua/custom/plugins/comment.lua index b838291e8a8..ae42754014d 100644 --- a/lua/custom/plugins/comment.lua +++ b/lua/custom/plugins/comment.lua @@ -1,2 +1,38 @@ -- "gc" to comment visual regions/lines -return { 'numToStr/Comment.nvim', opts = {} } +return { + 'numToStr/Comment.nvim', + config = function() + local prehook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook() + require('Comment').setup { + padding = true, + sticky = true, + ignore = '^$', + toggler = { + line = 'gcc', + block = 'gbc', + }, + opleader = { + line = 'gc', + block = 'gb', + }, + extra = { + above = 'gcO', + below = 'gco', + eol = 'gcA', + }, + mappings = { + basic = true, + extra = true, + extended = false, + }, + pre_hook = prehook, + post_hook = nil, + } + end, + event = 'BufReadPre', + lazy = false, + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'JoosepAlviste/nvim-ts-context-commentstring', + }, +} diff --git a/lua/custom/plugins/ts-comment.lua b/lua/custom/plugins/ts-comment.lua new file mode 100644 index 00000000000..15559d37826 --- /dev/null +++ b/lua/custom/plugins/ts-comment.lua @@ -0,0 +1 @@ +return { 'JoosepAlviste/nvim-ts-context-commentstring', opts = { enable_autocmd = false } } diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 9b45e25152c..546ddb979f5 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -10,9 +10,6 @@ return { -- Installs the debug adapters for you 'williamboman/mason.nvim', 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', }, config = function() local dap = require 'dap' @@ -86,7 +83,6 @@ return { vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close end, } diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index c793b885bc6..92c57020035 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -3,7 +3,7 @@ return { 'nvim-neo-tree/neo-tree.nvim', - version = '*', + version = 'v3.x', dependencies = { 'nvim-lua/plenary.nvim', 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended @@ -11,15 +11,17 @@ return { }, cmd = 'Neotree', keys = { - { '\\', ':Neotree reveal', { desc = 'NeoTree reveal' } }, + { 'pv', ':Neotree reveal=true position=float', { desc = 'NeoTree reveal' } }, }, opts = { - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, + window = { + mappings = { + [''] = 'close_window', }, }, + source_selector = { + winbar = true, + statusline = false, + }, }, } diff --git a/lua/plugins.lua b/lua/plugins.lua index c260f0bd963..902be70da27 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -15,7 +15,6 @@ require('lazy').setup({ { 'j-hui/fidget.nvim', opts = {} }, -- Useful status updates for LSP. 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - 'nvim-java/nvim-java', -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins -- used for completion, annotations and signatures of Neovim apis @@ -162,7 +161,11 @@ require('lazy').setup({ }, csharp_ls = {}, netcoredbg = {}, - clangd = {}, + clangd = { + init_options = { + fallbackFlags = { '--std=c++20' }, + }, + }, -- lua_ls = { @@ -237,6 +240,7 @@ require('lazy').setup({ } end, }, + 'nvim-java/nvim-java', { -- Autoformat 'stevearc/conform.nvim', @@ -477,7 +481,7 @@ require('lazy').setup({ -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps { import = 'custom.plugins' }, diff --git a/lua/remap.lua b/lua/remap.lua index 713636a1448..12fad1c970c 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -24,9 +24,6 @@ vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' } vim.keymap.set('v', 'J', ":m '>+1gv=gv") vim.keymap.set('v', 'K', ":m '<-2gv=gv") --- Open file tree -vim.keymap.set('n', 'pv', vim.cmd.Ex) - -- Keep cursor in place when appending next line vim.keymap.set('n', 'J', 'mzJ`z') From ac45b1953ceaa02c4d9d718b4792cfe2e9dcaf9c Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Wed, 18 Sep 2024 13:32:32 +0200 Subject: [PATCH 21/37] update to latest og version --- lua/custom/plugins/which-key.lua | 64 +++++++++++++------- lua/kickstart/health.lua | 6 +- lua/kickstart/plugins/lint.lua | 2 +- lua/kickstart/plugins/neo-tree.lua | 2 +- lua/plugins.lua | 93 ++++++++++++++++++------------ lua/remap.lua | 7 --- lua/set.lua | 5 +- 7 files changed, 108 insertions(+), 71 deletions(-) diff --git a/lua/custom/plugins/which-key.lua b/lua/custom/plugins/which-key.lua index cce7e5edaec..addc5996f95 100644 --- a/lua/custom/plugins/which-key.lua +++ b/lua/custom/plugins/which-key.lua @@ -1,29 +1,51 @@ return { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() - - -- Document existing key chains - require('which-key').add { - { 'c', group = '[C]ode' }, - { 'c_', hidden = true }, + opt = { + icons = { + -- set icon mappings to true if you have a Nerd Font + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, + spec = { + { 'c', group = '[C]ode', mode = { 'n', 'x' } }, { 'd', group = '[D]ocument' }, - { 'd_', hidden = true }, - { 'h', group = 'Git [H]unk' }, - { 'h_', hidden = true }, { 'r', group = '[R]ename' }, - { 'r_', hidden = true }, { 's', group = '[S]earch' }, - { 's_', hidden = true }, - { 't', group = '[T]oggle' }, - { 't_', hidden = true }, { 'w', group = '[W]orkspace' }, - { 'w_', hidden = true }, - } - -- visual mode - require('which-key').add { - { 'h', desc = 'Git [H]unk', mode = 'v' }, - } - end, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + }, + }, } diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua index 04df77b33e8..b59d08649af 100644 --- a/lua/kickstart/health.lua +++ b/lua/kickstart/health.lua @@ -6,13 +6,13 @@ --]] local check_version = function() - local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch) - if not vim.version.cmp then + local verstr = tostring(vim.version()) + if not vim.version.ge then vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) return end - if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then + if vim.version.ge(vim.version(), '0.10-dev') then vim.health.ok(string.format("Neovim version is: '%s'", verstr)) else vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 7f0dc42fbbf..ca9bc237904 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -47,7 +47,7 @@ return { vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { group = lint_augroup, callback = function() - require('lint').try_lint() + lint.try_lint() end, }) end, diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index 92c57020035..22c48ff3975 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -11,7 +11,7 @@ return { }, cmd = 'Neotree', keys = { - { 'pv', ':Neotree reveal=true position=float', { desc = 'NeoTree reveal' } }, + { 'pv', ':Neotree reveal=true position=float', desc = 'NeoTree reveal' }, }, opts = { window = { diff --git a/lua/plugins.lua b/lua/plugins.lua index 71d9ea606f7..7eae6f8ade1 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,7 +1,10 @@ local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then +if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + error('Error cloning lazy.nvim:\n' .. out) + end end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) @@ -9,6 +12,19 @@ require('lazy').setup({ 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically { -- LSP Configuration & Plugins + { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, + }, + { 'Bilal2453/luvit-meta', lazy = true }, 'neovim/nvim-lspconfig', dependencies = { { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants @@ -16,9 +32,8 @@ require('lazy').setup({ 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - { 'folke/neodev.nvim', opts = {} }, + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', }, config = function() vim.api.nvim_create_autocmd('LspAttach', { @@ -26,8 +41,9 @@ require('lazy').setup({ callback = function(event) -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end -- This is where a variable was first declared, or where a function is defined, etc. @@ -60,7 +76,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', vim.lsp.buf.code_action, '[C]ode [A]ction') + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap. @@ -76,7 +92,7 @@ require('lazy').setup({ -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.server_capabilities.documentHighlightProvider then + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, @@ -99,13 +115,13 @@ require('lazy').setup({ }) end - -- The following autocommand is used to enable inlay hints in your + -- The following code creates a keymap to toggle inlay hints in your -- code, if the language server you are using supports them -- -- This may be unwanted, since they displace some of your code - if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end end, @@ -184,7 +200,6 @@ require('lazy').setup({ fallbackFlags = { '--std=c++20' }, }, }, - clangd = {}, marksman = {}, -- @@ -243,7 +258,7 @@ require('lazy').setup({ local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) + -- certain features of an LSP (for example, turning off formatting for ts_ls) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, @@ -264,12 +279,13 @@ require('lazy').setup({ { -- Autoformat 'stevearc/conform.nvim', - lazy = false, + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, keys = { { 'f', function() - require('conform').format { async = true, lsp_fallback = true } + require('conform').format { async = true, lsp_format = 'fallback' } end, mode = '', desc = '[F]ormat buffer', @@ -282,9 +298,15 @@ require('lazy').setup({ -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end return { timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], + lsp_format = lsp_format_opt, } end, formatters_by_ft = { @@ -298,9 +320,8 @@ require('lazy').setup({ -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - -- javascript = { { "prettierd", "prettier" } }, + -- You can use 'stop_after_first' to run the first available formatter from the list + -- javascript = { "prettierd", "prettier", stop_after_first = true }, }, }, }, @@ -408,6 +429,11 @@ require('lazy').setup({ -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, sources = { + { + name = 'lazydev', + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, @@ -434,7 +460,7 @@ require('lazy').setup({ -- -- Examples: -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [']quote + -- - yinq - [Y]ank [I]nside [N]ext [Q]uote -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 } @@ -467,8 +493,10 @@ require('lazy').setup({ { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', + main = 'nvim-treesitter.configs', -- Sets main module to use for opts + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c', 'java' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -480,21 +508,12 @@ require('lazy').setup({ }, indent = { enable = true, disable = { 'ruby' } }, }, - config = function(_, opts) - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - - -- Prefer git instead of curl in order to improve connectivity in some environments - require('nvim-treesitter.install').prefer_git = true - ---@diagnostic disable-next-line: missing-fields - require('nvim-treesitter.configs').setup(opts) - - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects - end, + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, require 'kickstart.plugins.debug', diff --git a/lua/remap.lua b/lua/remap.lua index 12fad1c970c..52a7e963cc4 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -7,13 +7,6 @@ vim.keymap.set('i', 'jj', '') vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps -vim.keymap.set('n', '[d', function() - vim.diagnostic.jump { count = -1 } -end, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', function() - vim.diagnostic.jump { count = -1 } -end, { desc = 'Go to next [D]iagnostic message' }) -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' }) -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping diff --git a/lua/set.lua b/lua/set.lua index 73740608056..88be80df664 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -24,9 +24,12 @@ vim.opt.mouse = 'a' vim.opt.showmode = false -- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.opt.clipboard = 'unnamedplus' +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) -- Enable break indent vim.opt.breakindent = true From 54d8b950fd4f96ad4df046177526648739fec4e0 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Thu, 19 Sep 2024 15:00:31 +0200 Subject: [PATCH 22/37] add latex autocomplete --- lua/custom/plugins/cmp-vimtex.lua | 1 + lua/custom/plugins/vimtex.lua | 7 +++++++ lua/plugins.lua | 7 +++---- lua/set.lua | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 lua/custom/plugins/cmp-vimtex.lua create mode 100644 lua/custom/plugins/vimtex.lua diff --git a/lua/custom/plugins/cmp-vimtex.lua b/lua/custom/plugins/cmp-vimtex.lua new file mode 100644 index 00000000000..cc32af08d9b --- /dev/null +++ b/lua/custom/plugins/cmp-vimtex.lua @@ -0,0 +1 @@ +return { 'micangl/cmp-vimtex' } diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua new file mode 100644 index 00000000000..cfc0c37b382 --- /dev/null +++ b/lua/custom/plugins/vimtex.lua @@ -0,0 +1,7 @@ +return { + 'lervag/vimtex', + lazy = false, + init = function() + vim.g.vimtex_view_method = 'zathura' + end, +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 7eae6f8ade1..5be05dcef6a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -160,7 +160,6 @@ require('lazy').setup({ 'vue', }, }, - angularls = {}, stylelint_lsp = { filetypes = { 'css', 'scss' }, root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), @@ -200,7 +199,6 @@ require('lazy').setup({ fallbackFlags = { '--std=c++20' }, }, }, - marksman = {}, -- lua_ls = { @@ -316,7 +314,6 @@ require('lazy').setup({ json = { 'prettier' }, scss = { 'prettier' }, html = { 'prettier' }, - markdown = { 'prettier' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -437,6 +434,7 @@ require('lazy').setup({ { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, + { name = 'vimtex' }, }, } end, @@ -501,6 +499,7 @@ require('lazy').setup({ auto_install = true, highlight = { enable = true, + disable = { 'latex' }, -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. -- If you are experiencing weird indenting issues, add the language to -- the list of additional_vim_regex_highlighting and disabled languages for indent. @@ -519,7 +518,7 @@ require('lazy').setup({ require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.autopairs', require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps diff --git a/lua/set.lua b/lua/set.lua index 88be80df664..c90e7159463 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -54,7 +54,7 @@ vim.opt.smartcase = true vim.opt.signcolumn = 'yes' -- Decrease update time -vim.opt.updatetime = 50 +vim.opt.updatetime = 150 -- Decrease mapped sequence wait time -- Displays which-key popup sooner From 2e45c70b529de2bd4b5bc1b8d790c12232a1e9e0 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Fri, 20 Sep 2024 07:53:27 +0200 Subject: [PATCH 23/37] resolve merge --- lua/plugins.lua | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 5be05dcef6a..a4172093054 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -235,14 +235,11 @@ require('lazy').setup({ 'clang-format', 'lua_ls', 'omnisharp', - 'jdtls', - 'prettier', + 'prettierd', }) -- Skip automatic setup for servers - local skip_setup = { - 'jdtls', - } + local skip_setup = {} require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -260,20 +257,10 @@ require('lazy').setup({ server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, - jdtls = function() - require('java').setup { - -- Your custom jdtls settings goes here - } - - require('lspconfig').jdtls.setup { - -- Your custom nvim-java configuration goes here - } - end, }, } end, }, - 'nvim-java/nvim-java', { -- Autoformat 'stevearc/conform.nvim', @@ -309,11 +296,12 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, - typescript = { 'prettier' }, - javascript = { 'prettier' }, - json = { 'prettier' }, - scss = { 'prettier' }, - html = { 'prettier' }, + typescript = { 'prettierd' }, + javascript = { 'prettierd' }, + json = { 'prettierd' }, + scss = { 'prettierd' }, + html = { 'prettierd' }, + markdown = { 'prettierd' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -494,7 +482,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { From 3a798315e98fe3303a0bafeaab6e7440e251056a Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Fri, 20 Sep 2024 10:31:16 +0200 Subject: [PATCH 24/37] fix mason issue --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index a4172093054..80080c16595 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -261,6 +261,7 @@ require('lazy').setup({ } end, }, + 'nvim-java/nvim-java', -- removing this disables :Mason for some reason... { -- Autoformat 'stevearc/conform.nvim', From e28f39d75fd05ce445dd70accca06c1f47bebaf8 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Fri, 20 Sep 2024 17:14:49 +0200 Subject: [PATCH 25/37] FIIIIX --- lua/plugins.lua | 430 +++++++++++++++++++++++------------------------- 1 file changed, 209 insertions(+), 221 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 80080c16595..4df259ca5f5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -25,244 +25,232 @@ require('lazy').setup({ }, }, { 'Bilal2453/luvit-meta', lazy = true }, - 'neovim/nvim-lspconfig', - dependencies = { - { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants - { 'j-hui/fidget.nvim', opts = {} }, -- Useful status updates for LSP. - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Allows extra capabilities provided by nvim-cmp - 'hrsh7th/cmp-nvim-lsp', - }, - config = function() - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- 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 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. - -- 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 entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- 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 - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) - - -- 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') - - -- 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') + { + 'neovim/nvim-lspconfig', + dependencies = { + { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants + { 'j-hui/fidget.nvim', opts = {} }, -- Useful status updates for LSP. + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/cmp-nvim-lsp', + }, + config = function() + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) - end + -- 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 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. + -- 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 entire project. + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- 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 + -- or a suggestion from your LSP for this to activate. + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + + -- 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') + + -- 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). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end - end, - }) - - -- 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 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()) - - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - ts_ls = { - init_options = { - plugins = { - { - name = '@vue/typescript-plugin', - location = '/Users/fabianimhof/.nvm/versions/node/v16.20.2/lib/@vue/typescript-plugin', - languages = { 'javascript', 'typescript', 'vue' }, + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- 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 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()) + + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + ts_ls = { + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = '/Users/fabianimhof/.nvm/versions/node/v16.20.2/lib/@vue/typescript-plugin', + languages = { 'javascript', 'typescript', 'vue' }, + }, }, }, + filetypes = { + 'typescript', + 'typescriptreact', + 'javascript', + 'javascriptreact', + 'typescript.tsx', + 'vue', + }, }, - filetypes = { - 'typescript', - 'typescriptreact', - 'javascript', - 'javascriptreact', - 'typescript.tsx', - 'vue', - }, - }, - stylelint_lsp = { - filetypes = { 'css', 'scss' }, - root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), - settings = { - stylelintplus = { - autoFixOnFormat = true, - autoFixOnSave = true, + stylelint_lsp = { + filetypes = { 'css', 'scss' }, + root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), + settings = { + stylelintplus = { + autoFixOnFormat = true, + autoFixOnSave = true, + }, }, + on_attach = function(client) + client.server_capabilities.document_formatting = false + end, }, - on_attach = function(client) - client.server_capabilities.document_formatting = false - end, - }, - eslint = { - bin = 'eslint', -- or `eslint_d` - code_actions = { - enable = true, - apply_on_save = { + eslint = { + bin = 'eslint', -- or `eslint_d` + code_actions = { enable = true, - types = { 'directive', 'problem', 'suggestion', 'layout' }, + apply_on_save = { + enable = true, + types = { 'directive', 'problem', 'suggestion', 'layout' }, + }, + disable_rule_comment = { + enable = true, + location = 'separate_line', -- or `same_line` + }, }, - disable_rule_comment = { + diagnostics = { enable = true, - location = 'separate_line', -- or `same_line` + report_unused_disable_directives = false, + run_on = 'type', -- or `save` }, }, - diagnostics = { - enable = true, - report_unused_disable_directives = false, - run_on = 'type', -- or `save` - }, - }, - csharp_ls = {}, - netcoredbg = {}, - clangd = { - init_options = { - fallbackFlags = { '--std=c++20' }, + csharp_ls = {}, + netcoredbg = {}, + clangd = { + init_options = { + fallbackFlags = { '--std=c++20' }, + }, }, - }, - -- - - lua_ls = { - -- cmd = {...}, - -- filetypes = { ...}, - -- capabilities = {}, - settings = { - Lua = { - completion = { - callSnippet = 'Replace', + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + diagnostics = { disable = { 'missing-fields' } }, }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, }, }, - }, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - 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 - 'eslint_d', - 'stylelint', - 'clang-format', - 'lua_ls', - 'omnisharp', - 'prettierd', - }) - - -- Skip automatic setup for servers - local skip_setup = {} - - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - handlers = { - function(server_name) - if vim.tbl_contains(skip_setup, server_name) then - return - end + } - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, + -- Ensure the servers and tools above are installed + require('mason').setup() + + -- You can add other tools here that you want Mason to install + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Used to format Lua code + 'eslint_d', + 'stylelint', + 'clang-format', + 'omnisharp', + 'prettierd', + }) + + -- Skip automatic setup for servers + local skip_setup = {} + + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + if vim.tbl_contains(skip_setup, server_name) then + return + end + + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for ts_ls) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, + }, }, - 'nvim-java/nvim-java', -- removing this disables :Mason for some reason... - { -- Autoformat 'stevearc/conform.nvim', event = { 'BufWritePre' }, @@ -483,7 +471,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c' }, + ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c', 'cpp' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { From 5975e1b5732b93428c2da8517e8ab7ae67459053 Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Tue, 24 Sep 2024 22:21:33 +0200 Subject: [PATCH 26/37] spellchecking and devicons --- lua/custom/plugins/web-devicons.lua | 1 + lua/custom/plugins/which-key.lua | 3 +++ lua/set.lua | 5 +++++ 3 files changed, 9 insertions(+) create mode 100644 lua/custom/plugins/web-devicons.lua diff --git a/lua/custom/plugins/web-devicons.lua b/lua/custom/plugins/web-devicons.lua new file mode 100644 index 00000000000..6fc7b012fbd --- /dev/null +++ b/lua/custom/plugins/web-devicons.lua @@ -0,0 +1 @@ +return { 'nvim-tree/nvim-web-devicons' } diff --git a/lua/custom/plugins/which-key.lua b/lua/custom/plugins/which-key.lua index addc5996f95..a146b571e76 100644 --- a/lua/custom/plugins/which-key.lua +++ b/lua/custom/plugins/which-key.lua @@ -1,5 +1,8 @@ return { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, event = 'VimEnter', -- Sets the loading event to 'VimEnter' opt = { icons = { diff --git a/lua/set.lua b/lua/set.lua index c90e7159463..e713d6d6ea2 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -78,3 +78,8 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 + +-- Spellchecker +vim.opt.spelllang = 'en' +vim.opt.spell = true +vim.opt.spellfile = os.getenv 'HOME' .. '/.config/nvim/spell/en.utf-8.add' From 28f257fcb183895c09f0e4f988c7fdf04b3182d7 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Fri, 27 Sep 2024 10:58:23 +0200 Subject: [PATCH 27/37] remove default spellcheck --- lua/set.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/set.lua b/lua/set.lua index e713d6d6ea2..5e3535b3821 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -81,5 +81,4 @@ vim.opt.scrolloff = 10 -- Spellchecker vim.opt.spelllang = 'en' -vim.opt.spell = true vim.opt.spellfile = os.getenv 'HOME' .. '/.config/nvim/spell/en.utf-8.add' From 546a80891f2602800497d7e13a7c875393aeabb1 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Tue, 8 Oct 2024 17:37:28 +0200 Subject: [PATCH 28/37] update config for convenience --- lua/custom/plugins/telescope.lua | 1 + lua/kickstart/plugins/neo-tree.lua | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index 27731994961..a2360b9d51e 100644 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -35,6 +35,7 @@ return { -- Fuzzy Finder (files, lsp, etc) -- }, -- }, -- pickers = {} + defaults = { path_display = { 'smart' } }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index 22c48ff3975..1325f7fc24b 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -23,5 +23,10 @@ return { winbar = true, statusline = false, }, + -- NOTE: activate this to collapse empty folders -> might cause performance drop + -- filesystem = { + -- group_empty_dirs = true, + -- scan_mode = 'deep', + -- }, }, } From fa734bbf65a33546d1ddb39add76d27f01fba907 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Fri, 29 Nov 2024 12:03:43 +0100 Subject: [PATCH 29/37] fix stuff --- lua/custom/plugins/gitsigns.lua | 12 ------------ lua/custom/plugins/vimtex.lua | 7 +++++++ lua/plugins.lua | 23 +++-------------------- 3 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 lua/custom/plugins/gitsigns.lua diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua deleted file mode 100644 index 4f5441c7f9a..00000000000 --- a/lua/custom/plugins/gitsigns.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, -} diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua index cfc0c37b382..e114fbbc633 100644 --- a/lua/custom/plugins/vimtex.lua +++ b/lua/custom/plugins/vimtex.lua @@ -3,5 +3,12 @@ return { lazy = false, init = function() vim.g.vimtex_view_method = 'zathura' + vim.g.vimtex_compiler_latexmk = { + options = { + '-shell-escape', + '-pdf', + '-interaction=nonstopmode', + }, + } end, } diff --git a/lua/plugins.lua b/lua/plugins.lua index 4df259ca5f5..881daf63d2d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -142,25 +142,6 @@ require('lazy').setup({ -- - 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 = { - ts_ls = { - init_options = { - plugins = { - { - name = '@vue/typescript-plugin', - location = '/Users/fabianimhof/.nvm/versions/node/v16.20.2/lib/@vue/typescript-plugin', - languages = { 'javascript', 'typescript', 'vue' }, - }, - }, - }, - filetypes = { - 'typescript', - 'typescriptreact', - 'javascript', - 'javascriptreact', - 'typescript.tsx', - 'vue', - }, - }, stylelint_lsp = { filetypes = { 'css', 'scss' }, root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), @@ -196,6 +177,7 @@ require('lazy').setup({ csharp_ls = {}, netcoredbg = {}, clangd = { + cmd = { 'clangd', '--background-index', '--clang-tidy' }, init_options = { fallbackFlags = { '--std=c++20' }, }, @@ -286,6 +268,7 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, typescript = { 'prettierd' }, + typescriptreact = { 'prettierd' }, javascript = { 'prettierd' }, json = { 'prettierd' }, scss = { 'prettierd' }, @@ -497,7 +480,7 @@ require('lazy').setup({ -- require 'kickstart.plugins.lint', require 'kickstart.plugins.autopairs', require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps { import = 'custom.plugins' }, }, { From da871eb5ee848cde796613ea85f4cd633f637dc0 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Thu, 13 Mar 2025 16:56:24 +0100 Subject: [PATCH 30/37] add shortcuts for cmakebuild and run --- lua/custom/plugins/cmake-tools.lua | 6 ++++++ lua/remap.lua | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/custom/plugins/cmake-tools.lua b/lua/custom/plugins/cmake-tools.lua index 7964cf7c7e1..161b3556ce4 100644 --- a/lua/custom/plugins/cmake-tools.lua +++ b/lua/custom/plugins/cmake-tools.lua @@ -2,5 +2,11 @@ return { 'Civitasv/cmake-tools.nvim', config = function() require('cmake-tools').setup {} + + vim.keymap.set('n', 'mb', ':CMakeBuild') + vim.keymap.set('n', 'mr', ':CMakeRun') + + vim.keymap.set('n', 'mmb', ':CMakeBuildCurrentFile') + vim.keymap.set('n', 'mmr', ':CMakeRunCurrentFile') end, } diff --git a/lua/remap.lua b/lua/remap.lua index 52a7e963cc4..c8566478e6e 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -1,8 +1,6 @@ -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` -vim.keymap.set('i', 'jj', '') - -- clear higlight on search on pressing in normal mode vim.keymap.set('n', '', 'nohlsearch') From 4c2ade6e598318311e52df49fad764834f91e01a Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Wed, 21 May 2025 10:40:47 +0200 Subject: [PATCH 31/37] add typst lsp and preview package --- lua/custom/plugins/typst-preview.lua | 9 +++++++++ lua/plugins.lua | 1 + 2 files changed, 10 insertions(+) create mode 100644 lua/custom/plugins/typst-preview.lua diff --git a/lua/custom/plugins/typst-preview.lua b/lua/custom/plugins/typst-preview.lua new file mode 100644 index 00000000000..106d13249b2 --- /dev/null +++ b/lua/custom/plugins/typst-preview.lua @@ -0,0 +1,9 @@ +return { + 'chomosuke/typst-preview.nvim', + ft = 'typst', + version = '1.*', + opts = { + port = 56643, + dependencies_bin = { ['tinymist'] = 'tinymist' }, + }, +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 881daf63d2d..bf24277821a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -207,6 +207,7 @@ require('lazy').setup({ 'clang-format', 'omnisharp', 'prettierd', + 'tinymist', }) -- Skip automatic setup for servers From 0663b77784f04639aae58cba6b5196e97fb5c0ea Mon Sep 17 00:00:00 2001 From: TheSoeren Date: Wed, 21 May 2025 11:30:38 +0200 Subject: [PATCH 32/37] update colorcolumn to be more visible --- lua/plugins.lua | 4 +--- lua/set.lua | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index bf24277821a..46dd0a426cd 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -406,9 +406,7 @@ require('lazy').setup({ priority = 1000, -- Make sure to load this before all the other start plugins. init = function() vim.cmd.colorscheme 'tokyonight-night' - - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' + vim.api.nvim_set_hl(0, 'ColorColumn', { bg = '#2C2E22' }) end, }, diff --git a/lua/set.lua b/lua/set.lua index 5e3535b3821..1def6156da8 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -11,7 +11,7 @@ vim.opt.relativenumber = true vim.opt.termguicolors = true -vim.opt.colorcolumn = '100' +vim.opt.colorcolumn = '80' vim.g.have_nerd_font = false From ed66331b7285eff75d28a374452af3d2bcdf1492 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Wed, 21 May 2025 13:16:01 +0200 Subject: [PATCH 33/37] add typst formatter --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 46dd0a426cd..a293bac413c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -208,6 +208,7 @@ require('lazy').setup({ 'omnisharp', 'prettierd', 'tinymist', + 'prettypst', }) -- Skip automatic setup for servers From 1dfc84ae9128d7f4f0673cf235e3cf7db45413e8 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Wed, 21 May 2025 13:42:47 +0200 Subject: [PATCH 34/37] add prettypst --- lua/plugins.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index a293bac413c..74b6a6b3594 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -276,12 +276,18 @@ require('lazy').setup({ scss = { 'prettierd' }, html = { 'prettierd' }, markdown = { 'prettierd' }, + typst = { 'prettypst' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true }, }, + formatters = { + prettypst = { + prepend_args = { '--style=default', '--use-configuration' }, + }, + }, }, }, From c2dc755b4a3fa7ae1a628d30a29a6bfe0abe60ee Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Tue, 17 Jun 2025 14:14:25 +0200 Subject: [PATCH 35/37] update, deprecated, razor --- lua/custom/plugins/vim-razor.lua | 1 + lua/plugins.lua | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 lua/custom/plugins/vim-razor.lua diff --git a/lua/custom/plugins/vim-razor.lua b/lua/custom/plugins/vim-razor.lua new file mode 100644 index 00000000000..30bcea223ce --- /dev/null +++ b/lua/custom/plugins/vim-razor.lua @@ -0,0 +1 @@ +return { 'jlcrochet/vim-razor' } diff --git a/lua/plugins.lua b/lua/plugins.lua index 74b6a6b3594..f8b659e9c31 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -93,7 +93,7 @@ require('lazy').setup({ -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, @@ -120,7 +120,7 @@ require('lazy').setup({ -- code, if the language server you are using supports them -- -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') From 3be5adb2e162c11f7b0dad0fa4b13b8872591147 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Tue, 17 Jun 2025 14:36:21 +0200 Subject: [PATCH 36/37] replace csharp_ls with omnisharp --- lua/custom/plugins/csharpls-extended-lsp.lua | 1 - lua/custom/plugins/omnisharp-vim.lua | 1 + lua/plugins.lua | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 lua/custom/plugins/csharpls-extended-lsp.lua create mode 100644 lua/custom/plugins/omnisharp-vim.lua diff --git a/lua/custom/plugins/csharpls-extended-lsp.lua b/lua/custom/plugins/csharpls-extended-lsp.lua deleted file mode 100644 index f0cc03ab8dc..00000000000 --- a/lua/custom/plugins/csharpls-extended-lsp.lua +++ /dev/null @@ -1 +0,0 @@ -return { 'Decodetalkers/csharpls-extended-lsp.nvim' } diff --git a/lua/custom/plugins/omnisharp-vim.lua b/lua/custom/plugins/omnisharp-vim.lua new file mode 100644 index 00000000000..acdabd2353c --- /dev/null +++ b/lua/custom/plugins/omnisharp-vim.lua @@ -0,0 +1 @@ +return { 'OmniSharp/omnisharp-vim' } diff --git a/lua/plugins.lua b/lua/plugins.lua index f8b659e9c31..ab9fdba0f4b 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -174,7 +174,7 @@ require('lazy').setup({ run_on = 'type', -- or `save` }, }, - csharp_ls = {}, + omnisharp = {}, netcoredbg = {}, clangd = { cmd = { 'clangd', '--background-index', '--clang-tidy' }, From 4b2ae6540ef6124c4798d6d20b570654dab1b8a8 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Tue, 16 Dec 2025 15:41:42 +0100 Subject: [PATCH 37/37] update fork --- README.md | 71 +-- lua/autocommands.lua | 4 +- lua/custom/plugins/cmp-vimtex.lua | 1 - lua/custom/plugins/lazydev.lua | 12 + lua/custom/plugins/telescope.lua | 1 - lua/custom/plugins/vimtex.lua | 14 - lua/custom/plugins/which-key.lua | 12 +- lua/kickstart/plugins/autopairs.lua | 11 +- lua/kickstart/plugins/debug.lua | 67 ++- lua/kickstart/plugins/gitsigns.lua | 8 +- lua/kickstart/plugins/lint.lua | 7 +- lua/kickstart/plugins/neo-tree.lua | 4 +- lua/plugins.lua | 697 ++++++++++++++-------------- lua/remap.lua | 3 +- lua/set.lua | 73 +-- 15 files changed, 535 insertions(+), 450 deletions(-) delete mode 100644 lua/custom/plugins/cmp-vimtex.lua create mode 100644 lua/custom/plugins/lazydev.lua delete mode 100644 lua/custom/plugins/vimtex.lua diff --git a/README.md b/README.md index f988688b73b..58ceaea5875 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,24 @@ If you are experiencing issues, please make sure you have the latest versions. External Requirements: - Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) -- Clipboard tool (xclip/xsel/win32yank or other depending on platform) +- [ripgrep](https://github.com/BurntSushi/ripgrep#installation), + [fd-find](https://github.com/sharkdp/fd#installation) +- Clipboard tool (xclip/xsel/win32yank or other depending on the platform) - A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - if you have it set `vim.g.have_nerd_font` in `init.lua` to true +- Emoji fonts (Ubuntu only, and only if you want emoji!) `sudo apt install fonts-noto-color-emoji` - Language Setup: - - If want to write Typescript, you need `npm` - - If want to write Golang, you will need `go` + - If you want to write Typescript, you need `npm` + - If you want to write Golang, you will need `go` - etc. -> **NOTE** +> [!NOTE] > See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes > and quick install snippets ### Install Kickstart -> **NOTE** +> [!NOTE] > [Backup](#FAQ) your previous configuration (if any exists) Neovim's configurations are located under the following paths, depending on your OS: @@ -46,8 +48,8 @@ Neovim's configurations are located under the following paths, depending on your | OS | PATH | | :- | :--- | | Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | -| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | +| Windows (cmd)| `%localappdata%\nvim\` | +| Windows (powershell)| `$env:LOCALAPPDATA\nvim\` | #### Recommended Step @@ -55,15 +57,24 @@ Neovim's configurations are located under the following paths, depending on your so that you have your own copy that you can modify, then install by cloning the fork to your machine using one of the commands below, depending on your OS. -> **NOTE** -> Your fork's url will be something like this: +> [!NOTE] +> Your fork's URL will be something like this: > `https://github.com//kickstart.nvim.git` +You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file +too - it's ignored in the kickstart repo to make maintenance easier, but it's +[recommended to track it in version control](https://lazy.folke.io/usage/lockfile). + #### Clone kickstart.nvim + +> [!NOTE] +> If following the recommended step above (i.e., forking the repo), replace +> `nvim-lua` with `` in the commands below +
Linux and Mac ```sh -git clone https://github.com/TheSoeren/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim +git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim ```
@@ -73,13 +84,13 @@ git clone https://github.com/TheSoeren/kickstart.nvim.git "${XDG_CONFIG_HOME:-$H If you're using `cmd.exe`: ``` -git clone https://github.com/TheSoeren/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ +git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim" ``` If you're using `powershell.exe` ``` -git clone https://github.com/TheSoeren/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ +git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" ``` @@ -93,12 +104,17 @@ nvim ``` That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -current plugin status. Hit `q` to close the window. +the current plugin status. Hit `q` to close the window. + +#### Read The Friendly Documentation Read through the `init.lua` file in your configuration folder for more information about extending and exploring Neovim. That also includes examples of adding popularly requested plugins. +> [!NOTE] +> For more information about a particular plugin check its repository's documentation. + ### Getting Started @@ -106,9 +122,9 @@ examples of adding popularly requested plugins. ### FAQ -* What should I do if I already have a pre-existing neovim configuration? +* What should I do if I already have a pre-existing Neovim configuration? * You should back it up and then delete all associated files. - * This includes your existing init.lua and the neovim files in `~/.local` + * This includes your existing init.lua and the Neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` * 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` @@ -122,17 +138,17 @@ examples of adding popularly requested plugins. `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim distribution that you would like to try out. * What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information + * See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information * Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? * The main purpose of kickstart is to serve as a teaching tool and a reference configuration that someone can easily use to `git clone` as a basis for their own. As you progress in learning Neovim and Lua, you might consider splitting `init.lua` - into smaller parts. A fork of kickstart that does this while maintaining the + into smaller parts. A fork of kickstart that does this while maintaining the same functionality is available here: * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) * Discussions on this topic can be found here: - * [Restructure the configuration](https://github.com/TheSoeren/kickstart.nvim/issues/218) - * [Reorganize init.lua into a multi-file setup](https://github.com/TheSoeren/kickstart.nvim/pull/473) + * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) + * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) ### Install Recipes @@ -166,7 +182,7 @@ run in cmd as **admin**: winget install --accept-source-agreements chocolatey.chocolatey ``` -2. install all requirements using choco, exit previous cmd and +2. install all requirements using choco, exit the previous cmd and open a new one so that choco path is set, and run in cmd as **admin**: ``` choco install -y neovim git ripgrep wget fd unzip gzip mingw make @@ -199,14 +215,14 @@ sudo apt update sudo apt install make gcc ripgrep unzip git xclip curl # Now we install nvim -curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz -sudo rm -rf /opt/nvim-linux64 -sudo mkdir -p /opt/nvim-linux64 -sudo chmod a+rX /opt/nvim-linux64 -sudo tar -C /opt -xzf nvim-linux64.tar.gz +curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz +sudo rm -rf /opt/nvim-linux-x86_64 +sudo mkdir -p /opt/nvim-linux-x86_64 +sudo chmod a+rX /opt/nvim-linux-x86_64 +sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz # make it available in /usr/local/bin, distro installs to /usr/bin -sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/ +sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/ ```
Fedora Install Steps @@ -222,4 +238,3 @@ sudo dnf install -y gcc make git ripgrep fd-find unzip neovim sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim ```
- diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 533cb3c2472..4b8d1d584e8 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -3,11 +3,11 @@ -- Highlight when yanking (copying) text -- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` +-- See `:help vim.hl.on_yank()` vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Highlight when yanking (copying) text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() - vim.highlight.on_yank() + vim.hl.on_yank() end, }) diff --git a/lua/custom/plugins/cmp-vimtex.lua b/lua/custom/plugins/cmp-vimtex.lua deleted file mode 100644 index cc32af08d9b..00000000000 --- a/lua/custom/plugins/cmp-vimtex.lua +++ /dev/null @@ -1 +0,0 @@ -return { 'micangl/cmp-vimtex' } diff --git a/lua/custom/plugins/lazydev.lua b/lua/custom/plugins/lazydev.lua new file mode 100644 index 00000000000..447ce668751 --- /dev/null +++ b/lua/custom/plugins/lazydev.lua @@ -0,0 +1,12 @@ +return { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + }, + }, +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index a2360b9d51e..52da2cb6f6d 100644 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -1,7 +1,6 @@ return { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', event = 'VimEnter', - branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', { -- If encountering errors, see telescope-fzf-native README for installation instructions diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua deleted file mode 100644 index e114fbbc633..00000000000 --- a/lua/custom/plugins/vimtex.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 'lervag/vimtex', - lazy = false, - init = function() - vim.g.vimtex_view_method = 'zathura' - vim.g.vimtex_compiler_latexmk = { - options = { - '-shell-escape', - '-pdf', - '-interaction=nonstopmode', - }, - } - end, -} diff --git a/lua/custom/plugins/which-key.lua b/lua/custom/plugins/which-key.lua index a146b571e76..f8df159201a 100644 --- a/lua/custom/plugins/which-key.lua +++ b/lua/custom/plugins/which-key.lua @@ -4,12 +4,15 @@ return { -- Useful plugin to show you pending keybinds. 'nvim-tree/nvim-web-devicons', }, event = 'VimEnter', -- Sets the loading event to 'VimEnter' - opt = { + opts = { + -- delay between pressing a key and opening which-key (milliseconds) + -- this setting is independent of vim.o.timeoutlen + delay = 0, icons = { -- set icon mappings to true if you have a Nerd Font mappings = vim.g.have_nerd_font, -- If you are using a Nerd Font: set icons.keys to an empty table which will use the - -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table + -- default which-key.nvim defined Nerd Font icons, otherwise define a string table keys = vim.g.have_nerd_font and {} or { Up = ' ', Down = ' ', @@ -41,10 +44,9 @@ return { -- Useful plugin to show you pending keybinds. F12 = '', }, }, + + -- Document existing key chains spec = { - { 'c', group = '[C]ode', mode = { 'n', 'x' } }, - { 'd', group = '[D]ocument' }, - { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua index 87a7e5ffa2e..a993a7b7eda 100644 --- a/lua/kickstart/plugins/autopairs.lua +++ b/lua/kickstart/plugins/autopairs.lua @@ -1,16 +1,7 @@ -- autopairs -- https://github.com/windwp/nvim-autopairs - return { 'windwp/nvim-autopairs', event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, + opts = {}, } diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 546ddb979f5..eaf7a5fe83f 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -8,9 +8,62 @@ return { 'nvim-neotest/nvim-nio', -- Installs the debug adapters for you - 'williamboman/mason.nvim', + 'mason-org/mason.nvim', 'jay-babu/mason-nvim-dap.nvim', }, + keys = { + -- Basic debugging keymaps, feel free to change to your liking! + { + '', + function() + require('dap').continue() + end, + desc = 'Debug: Start/Continue', + }, + { + '', + function() + require('dap').step_into() + end, + desc = 'Debug: Step Into', + }, + { + '', + function() + require('dap').step_over() + end, + desc = 'Debug: Step Over', + }, + { + '', + function() + require('dap').step_out() + end, + desc = 'Debug: Step Out', + }, + { + 'b', + function() + require('dap').toggle_breakpoint() + end, + desc = 'Debug: Toggle Breakpoint', + }, + { + 'B', + function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, + desc = 'Debug: Set Breakpoint', + }, + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + { + '', + function() + require('dapui').toggle() + end, + desc = 'Debug: See last session result.', + }, + }, config = function() local dap = require 'dap' local dapui = require 'dapui' @@ -26,15 +79,6 @@ return { }, } - vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) - vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) - vim.keymap.set('n', 'B', function() - dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, { desc = 'Debug: Set Breakpoint' }) - -- Dap UI setup -- For more information, see |:help nvim-dap-ui| dapui.setup { @@ -79,9 +123,6 @@ return { }, } - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) - dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_exited['dapui_config'] = dapui.close end, diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index 4bcc70f4c79..cbbd22d24fc 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -36,15 +36,15 @@ return { -- visual mode map('v', 'hs', function() gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) + end, { desc = 'git [s]tage hunk' }) map('v', 'hr', function() gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) + end, { desc = 'git [r]eset hunk' }) -- normal mode map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', 'hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) @@ -54,7 +54,7 @@ return { end, { desc = 'git [D]iff against last commit' }) -- Toggles map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) + map('n', 'tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) end, }, }, diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index ca9bc237904..dec42f097c6 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -47,7 +47,12 @@ return { vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { group = lint_augroup, callback = function() - lint.try_lint() + -- Only run the linter in buffers that you can modify in order to + -- avoid superfluous noise, notably within the handy LSP pop-ups that + -- describe the hovered symbol using Markdown. + if vim.bo.modifiable then + lint.try_lint() + end end, }) end, diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index 1325f7fc24b..f82550a5c51 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -9,9 +9,9 @@ return { 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended 'MunifTanjim/nui.nvim', }, - cmd = 'Neotree', + lazy = false, keys = { - { 'pv', ':Neotree reveal=true position=float', desc = 'NeoTree reveal' }, + { 'pv', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { window = { diff --git a/lua/plugins.lua b/lua/plugins.lua index ab9fdba0f4b..afc095cac0f 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -5,235 +5,279 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then if vim.v.shell_error ~= 0 then error('Error cloning lazy.nvim:\n' .. out) end -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) +end + +---@type vim.Option +local rtp = vim.opt.rtp +rtp:prepend(lazypath) require('lazy').setup({ - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically { -- LSP Configuration & Plugins - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` + { 'mason-org/mason.nvim', opts = {} }, + 'mason-org/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP. + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- Allows extra capabilities provided by blink.cmp + { + 'saghen/blink.cmp', + opts = { + fuzzy = { + implementation = "lua" -- uses Lua, no Rust required + } + } }, + + -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + { 'folke/neodev.nvim', opts = {} }, }, - { 'Bilal2453/luvit-meta', lazy = true }, - { - 'neovim/nvim-lspconfig', - dependencies = { - { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants - { 'j-hui/fidget.nvim', opts = {} }, -- Useful status updates for LSP. - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Allows extra capabilities provided by nvim-cmp - 'hrsh7th/cmp-nvim-lsp', - }, - config = function() - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end + config = function() + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end - -- 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 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. - -- 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 entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- 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 - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) - - -- 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') - - -- 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). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('grn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) + + -- Find references for the word under your cursor. + map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + + -- 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('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + + -- 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') + + -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) + ---@param client vim.lsp.Client + ---@param method vim.lsp.protocol.Method + ---@param bufnr? integer some lsp support methods only in specific files + ---@return boolean + local function client_supports_method(client, method, bufnr) + if vim.fn.has 'nvim-0.11' == 1 then + return client:supports_method(method, bufnr) + else + return client.supports_method(method, { bufnr = bufnr }) end + end - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- Diagnostic Config + -- See :help vim.diagnostic.Opts + vim.diagnostic.config { + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = vim.g.have_nerd_font and { + text = { + [vim.diagnostic.severity.ERROR] = '󰅚 ', + [vim.diagnostic.severity.WARN] = '󰀪 ', + [vim.diagnostic.severity.INFO] = '󰋽 ', + [vim.diagnostic.severity.HINT] = '󰌶 ', + }, + } or {}, + virtual_text = { + source = 'if_many', + spacing = 2, + format = function(diagnostic) + local diagnostic_message = { + [vim.diagnostic.severity.ERROR] = diagnostic.message, + [vim.diagnostic.severity.WARN] = diagnostic.message, + [vim.diagnostic.severity.INFO] = diagnostic.message, + [vim.diagnostic.severity.HINT] = diagnostic.message, + } + return diagnostic_message[diagnostic.severity] end, - }) - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- 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()) - - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - stylelint_lsp = { - filetypes = { 'css', 'scss' }, - root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), - settings = { - stylelintplus = { - autoFixOnFormat = true, - autoFixOnSave = true, - }, + }, + } + + -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. + local capabilities = require('blink.cmp').get_lsp_capabilities() + + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + stylelint_lsp = { + filetypes = { 'css', 'scss' }, + root_dir = require('lspconfig').util.root_pattern('package.json', '.git'), + settings = { + stylelintplus = { + autoFixOnFormat = true, + autoFixOnSave = true, }, - on_attach = function(client) - client.server_capabilities.document_formatting = false - end, }, - eslint = { - bin = 'eslint', -- or `eslint_d` - code_actions = { + on_attach = function(client) + client.server_capabilities.document_formatting = false + end, + }, + eslint = { + bin = 'eslint', -- or `eslint_d` + code_actions = { + enable = true, + apply_on_save = { enable = true, - apply_on_save = { - enable = true, - types = { 'directive', 'problem', 'suggestion', 'layout' }, - }, - disable_rule_comment = { - enable = true, - location = 'separate_line', -- or `same_line` - }, + types = { 'directive', 'problem', 'suggestion', 'layout' }, }, - diagnostics = { + disable_rule_comment = { enable = true, - report_unused_disable_directives = false, - run_on = 'type', -- or `save` + location = 'separate_line', -- or `same_line` }, }, - omnisharp = {}, - netcoredbg = {}, - clangd = { - cmd = { 'clangd', '--background-index', '--clang-tidy' }, - init_options = { - fallbackFlags = { '--std=c++20' }, - }, + diagnostics = { + enable = true, + report_unused_disable_directives = false, + run_on = 'type', -- or `save` }, - lua_ls = { - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - diagnostics = { disable = { 'missing-fields' } }, + }, + omnisharp = {}, + netcoredbg = {}, + clangd = { + cmd = { 'clangd', '--background-index', '--clang-tidy' }, + init_options = { + fallbackFlags = { '--std=c++20' }, + }, + }, + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = 'Replace', }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + diagnostics = { disable = { 'missing-fields' } }, }, }, - } + }, + } - -- Ensure the servers and tools above are installed - require('mason').setup() - - -- You can add other tools here that you want Mason to install - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format Lua code - 'eslint_d', - 'stylelint', - 'clang-format', - 'omnisharp', - 'prettierd', - 'tinymist', - 'prettypst', - }) - - -- Skip automatic setup for servers - local skip_setup = {} - - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - handlers = { - function(server_name) - if vim.tbl_contains(skip_setup, server_name) then - return - end - - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, + -- You can add other tools here that you want Mason to install + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Used to format Lua code + 'eslint_d', + 'stylelint', + 'clang-format', + 'omnisharp', + 'prettierd', + }) + + -- Skip automatic setup for servers + local skip_setup = {} + + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + automatic_installation = false, + handlers = { + function(server_name) + if vim.tbl_contains(skip_setup, server_name) then + return + end + + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for ts_ls) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, }, { -- Autoformat 'stevearc/conform.nvim', @@ -252,20 +296,18 @@ require('lazy').setup({ opts = { notify_on_error = false, format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true } - local lsp_format_opt if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' + return nil else - lsp_format_opt = 'fallback' + return { + timeout_ms = 500, + lsp_format = 'fallback', + } end - return { - timeout_ms = 500, - lsp_format = lsp_format_opt, - } end, formatters_by_ft = { lua = { 'stylua' }, @@ -276,32 +318,28 @@ require('lazy').setup({ scss = { 'prettierd' }, html = { 'prettierd' }, markdown = { 'prettierd' }, - typst = { 'prettypst' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true }, }, - formatters = { - prettypst = { - prepend_args = { '--style=default', '--use-configuration' }, - }, - }, }, }, { -- Autocompletion - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', + 'saghen/blink.cmp', + event = 'VimEnter', + version = '1.*', dependencies = { - -- Snippet Engine & its associated nvim-cmp source + -- Snippet Engine { 'L3MON4D3/LuaSnip', + version = '2.*', build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end @@ -318,100 +356,83 @@ require('lazy').setup({ -- end, -- }, }, + opts = {}, }, - 'saadparwaiz1/cmp_luasnip', - - -- 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', }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` + --- @module 'blink.cmp' + --- @type blink.cmp.Config + opts = { + keymap = { + -- 'default' (recommended) for mappings similar to built-in completions + -- to accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + -- 'super-tab' for tab to accept + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- For an understanding of why the 'default' preset is recommended, + -- you will need to read `:help ins-completion` -- -- No, but seriously. Please read `:help ins-completion`, it is really good! - 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(), - - -- Scroll the documentation window [b]ack / [f]orward - [''] = 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 }, - - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), - - -- 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) - -- $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() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), + -- + -- All presets have the following mappings: + -- /: move to right/left of your snippet expansion + -- : Open menu or open docs if already open + -- / or /: Select next/previous item + -- : Hide menu + -- : Toggle signature help + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + preset = 'default', + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono', + }, - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + completion = { + -- By default, you may press `` to show the documentation. + -- Optionally, set `auto_show = true` to show the documentation after a delay. + documentation = { auto_show = false, auto_show_delay_ms = 500 }, }, + sources = { - { - name = 'lazydev', - -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0, + default = { 'lsp', 'path', 'snippets', 'lazydev' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, }, - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - { name = 'vimtex' }, }, + + snippets = { preset = 'luasnip' }, + + -- Blink.cmp includes an optional, recommended rust fuzzy matcher, + -- which automatically downloads a prebuilt binary when enabled. + -- + -- By default, we use the Lua implementation instead, but you may enable + -- the rust implementation via `'prefer_rust_with_warning'` + -- + -- See :h blink-cmp-config-fuzzy for more information + fuzzy = { implementation = 'lua' }, + + -- Shows a signature help window while you type arguments for a function + signature = { enabled = true }, } - end, + }, }, { -- You can easily change to a different colorscheme. 'folke/tokyonight.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() + config = function() + ---@diagnostic disable-next-line: missing-fields + require('tokyonight').setup { + styles = { + comments = { italic = false }, -- Disable italics in comments + }, + } vim.cmd.colorscheme 'tokyonight-night' vim.api.nvim_set_hl(0, 'ColorColumn', { bg = '#2C2E22' }) end, @@ -420,12 +441,12 @@ require('lazy').setup({ { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yinq - [Y]ank [I]nside [N]ext [Q]uote + -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 } -- Add/delete/replace surroundings (brackets, quotes, etc.) @@ -450,8 +471,8 @@ require('lazy').setup({ return '%2l:%-2v' end - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim + -- ... and there is more! + -- Check out: https://github.com/echasnovski/mini.nvim end, }, { -- Highlight, edit, and navigate code @@ -460,7 +481,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'c', 'cpp' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -489,24 +510,26 @@ require('lazy').setup({ require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps { import = 'custom.plugins' }, -}, { - ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the - -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table - icons = vim.g.have_nerd_font and {} or { - cmd = '⌘', - config = '🛠', - event = '📅', - ft = '📂', - init = '⚙', - keys = '🗝', - plugin = '🔌', - runtime = '💻', - require = '🌙', - source = '📄', - start = '🚀', - task = '📌', - lazy = '💤 ', +}, + { + ui = { + -- If you are using a Nerd Font: set icons to an empty table which will use the + -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table + icons = vim.g.have_nerd_font and {} or { + cmd = '⌘', + config = '🛠', + event = '📅', + ft = '📂', + init = '⚙', + keys = '🗝', + plugin = '🔌', + runtime = '💻', + require = '🌙', + source = '📄', + start = '🚀', + task = '📌', + lazy = '💤 ', + }, }, - }, -}) + } +) diff --git a/lua/remap.lua b/lua/remap.lua index c8566478e6e..9b7fe8be8e6 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -1,7 +1,8 @@ -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` --- clear higlight on search on pressing in normal mode +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps diff --git a/lua/set.lua b/lua/set.lua index 1def6156da8..613b976d729 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -1,83 +1,94 @@ -- [[ Setting options ]] --- See `:help vim.opt` +-- See `:help vim.o` -- NOTE: You can change these options as you wish! -- For more options, you can see `:help option-list` vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -vim.opt.nu = true -vim.opt.relativenumber = true +vim.o.nu = true +vim.o.relativenumber = true -vim.opt.termguicolors = true +vim.o.termguicolors = true -vim.opt.colorcolumn = '80' +vim.o.colorcolumn = '100' vim.g.have_nerd_font = false -vim.opt.hlsearch = true +vim.o.hlsearch = true -- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' +vim.o.mouse = 'a' -- Don't show the mode, since it's already in the status line -vim.opt.showmode = false +vim.o.showmode = false -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. +-- Schedule the setting after `UiEnter` because it can increase startup-time. -- See `:help 'clipboard'` vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' + vim.o.clipboard = 'unnamedplus' end) -- Enable break indent -vim.opt.breakindent = true -vim.opt.tabstop = 2 -vim.opt.softtabstop = 2 -vim.shiftwidth = 2 -vim.opt.expandtab = true -vim.opt.smartindent = true +vim.o.breakindent = true +vim.o.tabstop = 2 +vim.o.softtabstop = 2 +vim.o.shiftwidth = 2 +vim.o.expandtab = true +vim.o.smartindent = true -- Save undo history -vim.opt.wrap = false -vim.opt.swapfile = false -vim.opt.backup = false -vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir' -vim.opt.undofile = true +vim.o.wrap = false +vim.o.swapfile = false +vim.o.backup = false +vim.o.undodir = os.getenv 'HOME' .. '/.vim/undodir' +vim.o.undofile = true -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true -vim.opt.smartcase = true +vim.o.ignorecase = true +vim.o.smartcase = true -- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' +vim.o.signcolumn = 'yes' -- Decrease update time -vim.opt.updatetime = 150 +vim.o.updatetime = 150 -- Decrease mapped sequence wait time -- Displays which-key popup sooner -vim.opt.timeoutlen = 300 +vim.o.timeoutlen = 300 -- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true +vim.o.splitright = true +vim.o.splitbelow = true -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` -- and `:help 'listchars'` -vim.opt.list = true +-- +-- Notice listchars is set using `vim.opt` instead of `vim.o`. +-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. +-- See `:help lua-options` +-- and `:help lua-options-guide` +vim.o.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' +vim.o.inccommand = 'split' -- Show which line your cursor is on -vim.opt.cursorline = true +vim.o.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 +vim.o.scrolloff = 10 + +-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), +-- instead raise a dialog asking if you wish to save the current file(s) +-- See `:help 'confirm'` +vim.o.confirm = true -- Spellchecker vim.opt.spelllang = 'en'