From f54ae07b83c60e643476652502e8d67497c15f98 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Mon, 17 Jun 2024 19:11:12 +0100 Subject: [PATCH 01/41] move plugins into their own files --- init.lua | 338 +------------------------ lua/kickstart/plugins/autocomplete.lua | 110 ++++++++ lua/kickstart/plugins/mini.lua | 37 +++ lua/kickstart/plugins/telescope.lua | 111 ++++++++ lua/kickstart/plugins/tokyonight.lua | 17 ++ lua/kickstart/plugins/treesitter.lua | 32 +++ lua/kickstart/plugins/whichkey.lua | 37 +++ 7 files changed, 350 insertions(+), 332 deletions(-) create mode 100644 lua/kickstart/plugins/autocomplete.lua create mode 100644 lua/kickstart/plugins/mini.lua create mode 100644 lua/kickstart/plugins/telescope.lua create mode 100644 lua/kickstart/plugins/tokyonight.lua create mode 100644 lua/kickstart/plugins/treesitter.lua create mode 100644 lua/kickstart/plugins/whichkey.lua diff --git a/init.lua b/init.lua index 036eefb8c3b..3bd669775e3 100644 --- a/init.lua +++ b/init.lua @@ -273,140 +273,9 @@ require('lazy').setup({ -- 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 + require 'kickstart.plugins.whichkey', - { -- 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, - }, + require 'kickstart.plugins.telescope', { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', @@ -662,207 +531,12 @@ require('lazy').setup({ }, }, - { -- 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, - }, - + require 'kickstart.plugins.autocomplete', + require 'kickstart.plugins.tokyonight', -- 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', '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, - }, + require 'kickstart.plugins.mini', + require 'kickstart.plugins.treesitter', -- 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 diff --git a/lua/kickstart/plugins/autocomplete.lua b/lua/kickstart/plugins/autocomplete.lua new file mode 100644 index 00000000000..e9d05724fea --- /dev/null +++ b/lua/kickstart/plugins/autocomplete.lua @@ -0,0 +1,110 @@ +return { -- 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, +} \ No newline at end of file diff --git a/lua/kickstart/plugins/mini.lua b/lua/kickstart/plugins/mini.lua new file mode 100644 index 00000000000..a7439e4b290 --- /dev/null +++ b/lua/kickstart/plugins/mini.lua @@ -0,0 +1,37 @@ +return { -- 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, +} \ No newline at end of file diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua new file mode 100644 index 00000000000..a2eba371e12 --- /dev/null +++ b/lua/kickstart/plugins/telescope.lua @@ -0,0 +1,111 @@ +-- 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 + +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() + -- 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, +} \ No newline at end of file diff --git a/lua/kickstart/plugins/tokyonight.lua b/lua/kickstart/plugins/tokyonight.lua new file mode 100644 index 00000000000..eb2e3af08c9 --- /dev/null +++ b/lua/kickstart/plugins/tokyonight.lua @@ -0,0 +1,17 @@ +return { -- 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, +} \ No newline at end of file diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua new file mode 100644 index 00000000000..3cec8768c82 --- /dev/null +++ b/lua/kickstart/plugins/treesitter.lua @@ -0,0 +1,32 @@ +return { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + opts = { + ensure_installed = { 'bash', 'c', '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, +} \ No newline at end of file diff --git a/lua/kickstart/plugins/whichkey.lua b/lua/kickstart/plugins/whichkey.lua new file mode 100644 index 00000000000..aa5f6bbc067 --- /dev/null +++ b/lua/kickstart/plugins/whichkey.lua @@ -0,0 +1,37 @@ +-- 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 + +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').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, +} \ No newline at end of file From a65ca3852ae1de5d0b00b00d7fbbcbeda9dbaee8 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 18 Jun 2024 09:42:55 +0100 Subject: [PATCH 02/41] add pylsp and pyright --- init.lua | 219 +------------------------------- lua/kickstart/plugins/lsp.lua | 230 ++++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 217 deletions(-) create mode 100644 lua/kickstart/plugins/lsp.lua diff --git a/init.lua b/init.lua index 3bd669775e3..8fa0dc8079c 100644 --- a/init.lua +++ b/init.lua @@ -277,222 +277,7 @@ require('lazy').setup({ require 'kickstart.plugins.telescope', - { -- 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, - }) - 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, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf } - 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, - }, + require 'kickstart.plugins.lsp', { -- Autoformat 'stevearc/conform.nvim', @@ -537,7 +322,7 @@ require('lazy').setup({ { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, require 'kickstart.plugins.mini', require 'kickstart.plugins.treesitter', - + -- 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. diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua new file mode 100644 index 00000000000..217c4a393f7 --- /dev/null +++ b/lua/kickstart/plugins/lsp.lua @@ -0,0 +1,230 @@ +return { -- 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, + }) + 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, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf } + 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 = {}, + pylsp = { + on_attach = on_attach, + capabilities = capabilities, + settings = { + pylsp = { + plugins = { + pycodestyle = { + ignore = {}, + maxLineLength = 120, + }, + }, + }, + }, + } + -- 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, +} \ No newline at end of file From db15bab6927023c5acd3660f2e2f9832991c3e6a Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 18 Jun 2024 09:43:44 +0100 Subject: [PATCH 03/41] whoops forgot the separator --- lua/kickstart/plugins/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 217c4a393f7..681b5deaf40 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -171,7 +171,7 @@ return { -- LSP Configuration & Plugins }, }, }, - } + }, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- From 3f99900ede573e56530610d977dedc63150e5213 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Wed, 19 Jun 2024 10:02:57 +0100 Subject: [PATCH 04/41] add mason util and lsp changes for current state --- lua/kickstart/plugins/lsp.lua | 75 +++++++++++++++++++++++++++-------- lua/utils/mason.lua | 35 ++++++++++++++++ 2 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 lua/utils/mason.lua diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 681b5deaf40..5765b080a1e 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -1,4 +1,6 @@ -return { -- LSP Configuration & Plugins +return { + { + -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs and related tools to stdpath for Neovim @@ -157,21 +159,31 @@ return { -- LSP Configuration & Plugins local servers = { -- clangd = {}, -- gopls = {}, - pyright = {}, - pylsp = { - on_attach = on_attach, - capabilities = capabilities, - settings = { - pylsp = { - plugins = { - pycodestyle = { - ignore = {}, - maxLineLength = 120, - }, - }, - }, + pyright = { + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'workspace', + useLibraryCodeForTypes = true, + autoImportCompletions = true, + }, }, + }, + disableLanguageServices = false, }, + -- pylsp = { + -- settings = { + -- pylsp = { + -- plugins = { + -- pycodestyle = { + -- ignore = {}, + -- maxLineLength = 120, + -- }, + -- }, + -- } + -- } + -- }, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -212,7 +224,18 @@ return { -- LSP Configuration & Plugins vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } + -- require('mason-tool-installer').setup { ensure_installed = ensure_installed } + -- INFO: Using my own utils function instead of mason-lspconfig as it checks if the stuff is already installed + -- outside of mason. This is useful for NixOS setup where mason version just doesn't work sometimes due to libc issues. + require('utils.mason').install { + -- "python-lsp-server", + 'pyright', + 'bash-language-server', + -- "rnix-lsp", + 'lua-language-server', + -- "docker-compose-language-service", + -- "nil", + } require('mason-lspconfig').setup { handlers = { @@ -227,4 +250,24 @@ return { -- LSP Configuration & Plugins }, } end, -} \ No newline at end of file + }, + -- Show LSP explorer of functions and classes etc. + { + 'hedyhli/outline.nvim', + lazy = true, + cmd = { 'Outline', 'OutlineOpen' }, + keys = { -- Example mapping to toggle outline + { 'o', 'Outline', desc = 'Toggle outline' }, + }, + opts = {}, + }, + + -- Shows where you are in the file LSP wise (which class/function etc) + { + 'ray-x/lsp_signature.nvim', + event = 'VeryLazy', + config = function(_, opts) + require('lsp_signature').setup(opts) + end, + }, +} diff --git a/lua/utils/mason.lua b/lua/utils/mason.lua new file mode 100644 index 00000000000..f4ca5d0dc64 --- /dev/null +++ b/lua/utils/mason.lua @@ -0,0 +1,35 @@ +local M = {} + +-- any cases where name of package is different from the binary name +local name_to_bin = { + ["csharp-language-server"] = "csharp-ls", + ["python-lsp-server"] = "pylsp", + ["docker-compose-language-service"] = "docker-compose-langserver", +} + +M.install = function(ensure_installed) + -- Allow for passing in a single string + if type(ensure_installed) == "string" then + ensure_installed = { ensure_installed } + end + + -- Function to check if the executable exists in the PATH + local function executable_exists(name) + if name_to_bin[name] then + return vim.fn.executable(name) == 1 or vim.fn.executable(name_to_bin[name]) == 1 + end + return vim.fn.executable(name) == 1 + end + + local registry = require("mason-registry") + registry.refresh(function() + for _, pkg_name in ipairs(ensure_installed) do + local pkg = registry.get_package(pkg_name) + if not executable_exists(pkg_name) and not pkg:is_installed() then + pkg:install() + end + end + end) +end + +return M \ No newline at end of file From a7ebd6fde7f19820631d7fcb0edfc59f5edf0971 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Wed, 19 Jun 2024 11:20:21 +0100 Subject: [PATCH 05/41] configure lsps directly instead of with mason --- lua/kickstart/plugins/lsp.lua | 87 +++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 5765b080a1e..79f5a1fe713 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -46,6 +46,58 @@ return { -- 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 + local on_attach = function(_, buffr) + local kset = function(key, func, buffer, desc) + vim.keymap.set('n', key, func, { buffer = buffer, desc = 'LSP: ' .. desc }) + end + + print('Called on attach', _) + for k, v in pairs(_) do + print(k, v) + 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 . + kset('gd', require('telescope.builtin').lsp_definitions, buffr, '[G]oto [D]efinition') + + -- Find references for the word under your cursor. + kset('gr', require('telescope.builtin').lsp_references, buffr, '[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. + kset('gI', require('telescope.builtin').lsp_implementations, buffr, '[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*. + kset('D', require('telescope.builtin').lsp_type_definitions, buffr, 'Type [D]efinition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + kset('ds', require('telescope.builtin').lsp_document_symbols, buffr, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + kset('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, buffr, '[W]orkspace [S]ymbols') + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + kset('rn', vim.lsp.buf.rename, buffr, '[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. + kset('ca', vim.lsp.buf.code_action, buffr, '[C]ode [A]ction') + + -- Opens a popup that displays documentation about the word under your cursor + -- See `:help K` for why this keymap. + kset('K', vim.lsp.buf.hover, buffr, 'Hover Documentation') + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + kset('gD', vim.lsp.buf.declaration, buffr, '[G]oto [D]eclaration') + end + vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) @@ -216,7 +268,7 @@ return { -- :Mason -- -- You can press `g?` for help in this menu. - require('mason').setup() + -- require('mason').setup() -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. @@ -237,18 +289,27 @@ return { -- "nil", } - 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, - }, - } + local lsp = require 'lspconfig' + + for server, config in pairs(servers) do + print(server) + config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) + config.on_attach = on_attach + lsp[server].setup(config) + end + + -- 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, }, -- Show LSP explorer of functions and classes etc. From 33554a5315f3d12727ec093dad295d2b3b237bdf Mon Sep 17 00:00:00 2001 From: peturparkur Date: Fri, 21 Jun 2024 11:09:59 +0100 Subject: [PATCH 06/41] add basedpyright and allow inlay hints by default --- lua/kickstart/plugins/lsp.lua | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 79f5a1fe713..af497077de0 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -17,6 +17,9 @@ return { { 'folke/neodev.nvim', opts = {} }, }, config = function() + -- some default parameters + vim.lsp.inlay_hint.enable(true, nil) + -- Brief aside: **What is LSP?** -- -- LSP is an initialism you've probably heard, but might not understand what it is. @@ -51,11 +54,6 @@ return { vim.keymap.set('n', key, func, { buffer = buffer, desc = 'LSP: ' .. desc }) end - print('Called on attach', _) - for k, v in pairs(_) do - print(k, v) - 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 . @@ -151,6 +149,8 @@ return { -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + print('LSP attach event for ', event.data, event.data.client_id) + -- 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 @@ -211,18 +211,28 @@ return { local servers = { -- clangd = {}, -- gopls = {}, - pyright = { + -- pyright = { + -- settings = { + -- python = { + -- analysis = { + -- autoSearchPaths = true, + -- diagnosticMode = 'workspace', + -- useLibraryCodeForTypes = true, + -- autoImportCompletions = true, + -- }, + -- }, + -- }, + -- disableLanguageServices = false, + -- }, + basedpyright = { settings = { - python = { + basedpyright = { analysis = { autoSearchPaths = true, - diagnosticMode = 'workspace', - useLibraryCodeForTypes = true, - autoImportCompletions = true, + typeCheckingMode = 'standard', }, }, }, - disableLanguageServices = false, }, -- pylsp = { -- settings = { @@ -282,6 +292,7 @@ return { require('utils.mason').install { -- "python-lsp-server", 'pyright', + 'basedpyright', 'bash-language-server', -- "rnix-lsp", 'lua-language-server', @@ -292,7 +303,6 @@ return { local lsp = require 'lspconfig' for server, config in pairs(servers) do - print(server) config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) config.on_attach = on_attach lsp[server].setup(config) From 7db85cf0aed8010d6aafba7215d423c792676910 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Thu, 27 Jun 2024 20:52:05 +0100 Subject: [PATCH 07/41] better lsp handling + utility to only check mason if not found locally installed --- lua/kickstart/plugins/lsp.lua | 64 ++++++++++++++++++++++------------- lua/utils/mason.lua | 50 ++++++++++++++------------- 2 files changed, 66 insertions(+), 48 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index af497077de0..8744d00ecba 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -211,19 +211,19 @@ return { local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = { - -- settings = { - -- python = { - -- analysis = { - -- autoSearchPaths = true, - -- diagnosticMode = 'workspace', - -- useLibraryCodeForTypes = true, - -- autoImportCompletions = true, - -- }, - -- }, - -- }, - -- disableLanguageServices = false, - -- }, + pyright = { + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'workspace', + useLibraryCodeForTypes = true, + autoImportCompletions = true, + }, + }, + }, + disableLanguageServices = false, + }, basedpyright = { settings = { basedpyright = { @@ -255,11 +255,15 @@ return { -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- - + nixd = {}, + bashls = { + alias = 'bash-language-server', + }, lua_ls = { -- cmd = {...}, -- filetypes = { ...}, -- capabilities = {}, + alias = 'lua-language-server', settings = { Lua = { completion = { @@ -289,16 +293,28 @@ return { -- require('mason-tool-installer').setup { ensure_installed = ensure_installed } -- INFO: Using my own utils function instead of mason-lspconfig as it checks if the stuff is already installed -- outside of mason. This is useful for NixOS setup where mason version just doesn't work sometimes due to libc issues. - require('utils.mason').install { - -- "python-lsp-server", - 'pyright', - 'basedpyright', - 'bash-language-server', - -- "rnix-lsp", - 'lua-language-server', - -- "docker-compose-language-service", - -- "nil", - } + local installed = {} + local i = 0 + for server, config in pairs(servers) do + if config.alias then + installed[i] = config.alias + else + installed[i] = server + end + i = i + 1 + end + table.insert(installed, 'stylua') + require('utils.mason').install(installed) + -- require('utils.mason').install { + -- -- "python-lsp-server", + -- 'pyright', + -- 'basedpyright', + -- 'bash-language-server', + -- -- "rnix-lsp", + -- 'lua-language-server', + -- -- "docker-compose-language-service", + -- -- "nil", + -- } local lsp = require 'lspconfig' diff --git a/lua/utils/mason.lua b/lua/utils/mason.lua index f4ca5d0dc64..e5553c7511e 100644 --- a/lua/utils/mason.lua +++ b/lua/utils/mason.lua @@ -2,34 +2,36 @@ local M = {} -- any cases where name of package is different from the binary name local name_to_bin = { - ["csharp-language-server"] = "csharp-ls", - ["python-lsp-server"] = "pylsp", - ["docker-compose-language-service"] = "docker-compose-langserver", + ['csharp-language-server'] = 'csharp-ls', + ['python-lsp-server'] = 'pylsp', + ['docker-compose-language-service'] = 'docker-compose-langserver', } M.install = function(ensure_installed) - -- Allow for passing in a single string - if type(ensure_installed) == "string" then - ensure_installed = { ensure_installed } - end + -- Allow for passing in a single string + if type(ensure_installed) == 'string' then + ensure_installed = { ensure_installed } + end - -- Function to check if the executable exists in the PATH - local function executable_exists(name) - if name_to_bin[name] then - return vim.fn.executable(name) == 1 or vim.fn.executable(name_to_bin[name]) == 1 - end - return vim.fn.executable(name) == 1 - end + -- Function to check if the executable exists in the PATH + local function executable_exists(name) + if name_to_bin[name] then + return vim.fn.executable(name_to_bin[name]) == 1 + end + return vim.fn.executable(name) == 1 + end - local registry = require("mason-registry") - registry.refresh(function() - for _, pkg_name in ipairs(ensure_installed) do - local pkg = registry.get_package(pkg_name) - if not executable_exists(pkg_name) and not pkg:is_installed() then - pkg:install() - end - end - end) + local registry = require 'mason-registry' + registry.refresh(function() + for _, pkg_name in ipairs(ensure_installed) do + if not executable_exists(pkg_name) then + local pkg = registry.get_package(pkg_name) + if not pkg:is_installed() then + pkg:install() + end + end + end + end) end -return M \ No newline at end of file +return M From 5d516ba85f8c904e7fec7d1e6d2d161d72290565 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Thu, 4 Jul 2024 20:57:14 +0100 Subject: [PATCH 08/41] move tokyonight to themes folder --- init.lua | 4 ++-- lua/kickstart/plugins/{ => themes}/tokyonight.lua | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename lua/kickstart/plugins/{ => themes}/tokyonight.lua (100%) diff --git a/init.lua b/init.lua index 8fa0dc8079c..ef87ab65885 100644 --- a/init.lua +++ b/init.lua @@ -317,12 +317,12 @@ require('lazy').setup({ }, require 'kickstart.plugins.autocomplete', - require 'kickstart.plugins.tokyonight', + require 'kickstart.plugins.themes.tokyonight', -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, require 'kickstart.plugins.mini', require 'kickstart.plugins.treesitter', - + -- 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. diff --git a/lua/kickstart/plugins/tokyonight.lua b/lua/kickstart/plugins/themes/tokyonight.lua similarity index 100% rename from lua/kickstart/plugins/tokyonight.lua rename to lua/kickstart/plugins/themes/tokyonight.lua From 60ca6777e26f84c7c7eb75ea678abac405e48ca6 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Thu, 4 Jul 2024 21:14:27 +0100 Subject: [PATCH 09/41] add themes and change initial theme --- init.lua | 4 +++- lua/kickstart/plugins/themes/catppuccin.lua | 18 ++++++++++++++++++ lua/kickstart/plugins/themes/github_nvim.lua | 12 ++++++++++++ lua/kickstart/plugins/themes/kanagawa.lua | 12 ++++++++++++ lua/kickstart/plugins/themes/nightfox.lua | 12 ++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 lua/kickstart/plugins/themes/catppuccin.lua create mode 100644 lua/kickstart/plugins/themes/github_nvim.lua create mode 100644 lua/kickstart/plugins/themes/kanagawa.lua create mode 100644 lua/kickstart/plugins/themes/nightfox.lua diff --git a/init.lua b/init.lua index ef87ab65885..a8002063a42 100644 --- a/init.lua +++ b/init.lua @@ -317,7 +317,9 @@ require('lazy').setup({ }, require 'kickstart.plugins.autocomplete', - require 'kickstart.plugins.themes.tokyonight', + -- THEMES + -- require 'kickstart.plugins.themes.tokyonight', + require 'kickstart.plugins.themes.catppuccin', -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, require 'kickstart.plugins.mini', diff --git a/lua/kickstart/plugins/themes/catppuccin.lua b/lua/kickstart/plugins/themes/catppuccin.lua new file mode 100644 index 00000000000..8fec85e891d --- /dev/null +++ b/lua/kickstart/plugins/themes/catppuccin.lua @@ -0,0 +1,18 @@ +return { -- 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`. + 'catppuccin/nvim', + name = 'catppuccin', + 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 'catppuccin' + + -- You can configure highlights by doing something like: + -- vim.cmd.hi 'Comment gui=none' + end, +} diff --git a/lua/kickstart/plugins/themes/github_nvim.lua b/lua/kickstart/plugins/themes/github_nvim.lua new file mode 100644 index 00000000000..d1c85955904 --- /dev/null +++ b/lua/kickstart/plugins/themes/github_nvim.lua @@ -0,0 +1,12 @@ +return { + 'projekt0n/github-nvim-theme', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + require('github-theme').setup { + -- ... + } + + vim.cmd 'colorscheme github_dark' + end, +} diff --git a/lua/kickstart/plugins/themes/kanagawa.lua b/lua/kickstart/plugins/themes/kanagawa.lua new file mode 100644 index 00000000000..835130638eb --- /dev/null +++ b/lua/kickstart/plugins/themes/kanagawa.lua @@ -0,0 +1,12 @@ +return { + 'rebelot/kanagawa.nvim', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + require('kanagawa').setup { + -- ... + } + + vim.cmd 'colorscheme kanagawa' + end, +} diff --git a/lua/kickstart/plugins/themes/nightfox.lua b/lua/kickstart/plugins/themes/nightfox.lua new file mode 100644 index 00000000000..3054d0ef35d --- /dev/null +++ b/lua/kickstart/plugins/themes/nightfox.lua @@ -0,0 +1,12 @@ +return { + 'EdenEast/nightfox.nvim', + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + require('nightfox').setup { + -- ... + } + + vim.cmd 'colorscheme nightfox' + end, +} From 0ef7ddd017a56e9399ca8e7fae25afe294c97a7b Mon Sep 17 00:00:00 2001 From: peturparkur Date: Thu, 4 Jul 2024 21:26:45 +0100 Subject: [PATCH 10/41] enable neo-tree --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a8002063a42..6cec6be5394 100644 --- a/init.lua +++ b/init.lua @@ -338,7 +338,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 -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` From f2e977c94438c65764aaf01dd49919636d095049 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Fri, 5 Jul 2024 13:34:06 +0100 Subject: [PATCH 11/41] remove on-attach print --- lua/kickstart/plugins/lsp.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 8744d00ecba..5c9ba1ee115 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -149,8 +149,6 @@ return { -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - print('LSP attach event for ', event.data, event.data.client_id) - -- 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 From 340e1ad0ecc0d756032aab05e91c12abed7d6b13 Mon Sep 17 00:00:00 2001 From: nagymathev Date: Wed, 10 Jul 2024 10:44:15 +0100 Subject: [PATCH 12/41] relative numbers --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 6cec6be5394..7e13dad54a2 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false 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 +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' From ec42464b081e02809a75eab2fb6ad18fa725dd13 Mon Sep 17 00:00:00 2001 From: nagymathev Date: Wed, 10 Jul 2024 11:05:43 +0100 Subject: [PATCH 13/41] replace nixd with nil --- lua/kickstart/plugins/lsp.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 5c9ba1ee115..7d4c09e2d7c 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -253,7 +253,9 @@ return { -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- - nixd = {}, + ['nil_ls'] = { + alias = 'nil', + }, bashls = { alias = 'bash-language-server', }, From 9f2234ad68f4aae3b1659ce5a6cd0702dd6284a5 Mon Sep 17 00:00:00 2001 From: nagymathev Date: Wed, 10 Jul 2024 11:14:58 +0100 Subject: [PATCH 14/41] add rust lsp --- lua/kickstart/plugins/lsp.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 7d4c09e2d7c..82e45740694 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -244,7 +244,9 @@ return { -- } -- } -- }, - -- rust_analyzer = {}, + rust_analyzer = { + alias = '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: From d3adf6a4b8bac6e8d10571d4046867f11a92dc89 Mon Sep 17 00:00:00 2001 From: nagymathev Date: Wed, 10 Jul 2024 16:27:01 +0100 Subject: [PATCH 15/41] markdown lsp --- lua/kickstart/plugins/lsp.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 82e45740694..570a7b4c4a3 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -238,7 +238,7 @@ return { -- plugins = { -- pycodestyle = { -- ignore = {}, - -- maxLineLength = 120, + -- maxLineLength = 120, -- }, -- }, -- } @@ -247,6 +247,10 @@ return { rust_analyzer = { alias = 'rust-analyzer', }, + + markdown_oxide = { + alias = 'markdown-oxide', + }, -- ... 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: From 27e15143a3ac4e4bcbe7afe65c6ec9b2d40b3ce2 Mon Sep 17 00:00:00 2001 From: nagymathev Date: Fri, 12 Jul 2024 13:59:16 +0100 Subject: [PATCH 16/41] enable autopairs --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 7e13dad54a2..858ccf2a0c9 100644 --- a/init.lua +++ b/init.lua @@ -279,6 +279,7 @@ require('lazy').setup({ require 'kickstart.plugins.lsp', + require 'kickstart.plugins.autopairs', { -- Autoformat 'stevearc/conform.nvim', lazy = false, From 3025004d617a5374d7c77498472959ba9e914d91 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Fri, 26 Jul 2024 09:39:08 +0100 Subject: [PATCH 17/41] fix alignment and add back nixd --- lua/kickstart/plugins/lsp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 570a7b4c4a3..96ae0e1d4b8 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -238,7 +238,7 @@ return { -- plugins = { -- pycodestyle = { -- ignore = {}, - -- maxLineLength = 120, + -- maxLineLength = 120, -- }, -- }, -- } @@ -259,6 +259,7 @@ return { -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + nixd = {}, ['nil_ls'] = { alias = 'nil', }, From f207404efcb376c06c9a82723389b7e6da700708 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Fri, 26 Jul 2024 10:10:28 +0100 Subject: [PATCH 18/41] add toggleterm --- init.lua | 8 +++----- lua/custom/plugins/toggleterm.lua | 11 +++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 lua/custom/plugins/toggleterm.lua diff --git a/init.lua b/init.lua index 858ccf2a0c9..7000c973f5a 100644 --- a/init.lua +++ b/init.lua @@ -278,8 +278,6 @@ require('lazy').setup({ require 'kickstart.plugins.telescope', require 'kickstart.plugins.lsp', - - require 'kickstart.plugins.autopairs', { -- Autoformat 'stevearc/conform.nvim', lazy = false, @@ -336,9 +334,9 @@ require('lazy').setup({ -- 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.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 @@ -347,7 +345,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/lua/custom/plugins/toggleterm.lua b/lua/custom/plugins/toggleterm.lua new file mode 100644 index 00000000000..a7681921831 --- /dev/null +++ b/lua/custom/plugins/toggleterm.lua @@ -0,0 +1,11 @@ +return { + 'akinsho/toggleterm.nvim', + version = '*', + opts = {}, + config = function(_, opts) + require('toggleterm').setup { + open_mapping = [[]], + direction = 'float', + } + end, +} From 6f49fd38ba35473052ef69d2bd29aaea819c7f77 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Sat, 24 Aug 2024 09:35:51 +0100 Subject: [PATCH 19/41] add gopls language server --- lua/kickstart/plugins/lsp.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 96ae0e1d4b8..53ae062af86 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -232,6 +232,7 @@ return { }, }, }, + gopls = {}, -- pylsp = { -- settings = { -- pylsp = { From e8eeff8fd678a0e95d63f4241727973a2809aa29 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Sat, 24 Aug 2024 10:32:44 +0100 Subject: [PATCH 20/41] add dockerfile and dockercompose LSPs + optional local enforcement --- lua/kickstart/plugins/lsp.lua | 9 +++++++-- lua/utils/mason.lua | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 53ae062af86..45c9e02c3fe 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -208,7 +208,6 @@ return { -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, pyright = { settings = { python = { @@ -267,6 +266,12 @@ return { bashls = { alias = 'bash-language-server', }, + dockerls = { + alias = 'docker-langserver', + }, + docker_compose_language_service = { + alias = 'docker-compose-langserver', + }, lua_ls = { -- cmd = {...}, -- filetypes = { ...}, @@ -312,7 +317,7 @@ return { i = i + 1 end table.insert(installed, 'stylua') - require('utils.mason').install(installed) + require('utils.mason').install(installed, true) -- require('utils.mason').install { -- -- "python-lsp-server", -- 'pyright', diff --git a/lua/utils/mason.lua b/lua/utils/mason.lua index e5553c7511e..0b58974054a 100644 --- a/lua/utils/mason.lua +++ b/lua/utils/mason.lua @@ -7,12 +7,17 @@ local name_to_bin = { ['docker-compose-language-service'] = 'docker-compose-langserver', } -M.install = function(ensure_installed) +-- We guarantee 'ensure_installed' package is installed locally +-- If enforce_local is false then we install it via mason-registry +-- By default we install LSPs via mason +M.install = function(ensure_installed, enforce_local) -- Allow for passing in a single string if type(ensure_installed) == 'string' then ensure_installed = { ensure_installed } end + enforce_local = enforce_local == nil and false or enforce_local + -- Function to check if the executable exists in the PATH local function executable_exists(name) if name_to_bin[name] then @@ -24,7 +29,7 @@ M.install = function(ensure_installed) local registry = require 'mason-registry' registry.refresh(function() for _, pkg_name in ipairs(ensure_installed) do - if not executable_exists(pkg_name) then + if (not executable_exists(pkg_name)) and not enforce_local then local pkg = registry.get_package(pkg_name) if not pkg:is_installed() then pkg:install() From 10a642227256d5177c2cc0ff048299fe9800ab78 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Sat, 24 Aug 2024 14:32:22 +0200 Subject: [PATCH 21/41] gopls explicit settings --- lua/kickstart/plugins/lsp.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 45c9e02c3fe..3a24dd64093 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -231,7 +231,17 @@ return { }, }, }, - gopls = {}, + gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, + }, -- pylsp = { -- settings = { -- pylsp = { From 7f443fb843fe33fd0391ca44923568254582730e Mon Sep 17 00:00:00 2001 From: peturparkur Date: Sat, 24 Aug 2024 15:27:12 +0200 Subject: [PATCH 22/41] remove pylyzer and go compatible with inlay hints --- lua/kickstart/plugins/lsp.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 3a24dd64093..62a8fd453e6 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -174,7 +174,16 @@ return { -- 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 + local function dump_table(tbl) + local result = '' + for k, v in pairs(tbl) do + result = result .. (k .. ': ' .. tostring(v)) .. ',\t' + end + return string.sub(result, 1, -2) + end + + vim.lsp.inlay_hint.enable(true) + if client and client.server_capabilities.inlayHintProvider then map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, '[T]oggle Inlay [H]ints') @@ -226,7 +235,9 @@ return { basedpyright = { analysis = { autoSearchPaths = true, - typeCheckingMode = 'standard', + typeCheckingMode = 'basic', + diagnosticMode = 'openFilesOnly', + useLibraryCodeForTypes = true, }, }, }, @@ -238,6 +249,15 @@ return { unusedparams = true, }, staticcheck = true, + hints = { + rangeVariableTypes = true, + parameterNames = true, + constantValues = true, + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + functionTypeParameters = true, + }, gofumpt = true, }, }, From 7eba0efed590e8ba8452ca70880df038cb13a62b Mon Sep 17 00:00:00 2001 From: peturparkur Date: Wed, 28 Aug 2024 15:55:10 +0200 Subject: [PATCH 23/41] lsp detection for docker compose yaml files --- init.lua | 7 +++++++ lua/utils/mason.lua | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 7000c973f5a..e980abef66a 100644 --- a/init.lua +++ b/init.lua @@ -204,6 +204,13 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- vim.api.nvim_create_augroup('DockerFileTypeDetection', { clear = true }) +vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { + pattern = { 'docker-compose.yaml', 'compose.yaml' }, + command = 'set filetype=yaml.docker-compose', + -- group = 'DockerFileTypeDetection', +}) + -- [[ 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' diff --git a/lua/utils/mason.lua b/lua/utils/mason.lua index 0b58974054a..4ad6c2a8aad 100644 --- a/lua/utils/mason.lua +++ b/lua/utils/mason.lua @@ -2,9 +2,9 @@ local M = {} -- any cases where name of package is different from the binary name local name_to_bin = { - ['csharp-language-server'] = 'csharp-ls', - ['python-lsp-server'] = 'pylsp', - ['docker-compose-language-service'] = 'docker-compose-langserver', + -- ['csharp-language-server'] = 'csharp-ls', + -- ['python-lsp-server'] = 'pylsp', + -- ['docker-compose-language-service'] = 'docker-compose-langserver', } -- We guarantee 'ensure_installed' package is installed locally From 990efd1444e70e05f54b0286b491803235059d6b Mon Sep 17 00:00:00 2001 From: peturparkur Date: Thu, 29 Aug 2024 11:44:41 +0200 Subject: [PATCH 24/41] better filename and extension definition for docker-compose recognition --- init.lua | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index e980abef66a..20f471fa5d1 100644 --- a/init.lua +++ b/init.lua @@ -204,12 +204,28 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) --- vim.api.nvim_create_augroup('DockerFileTypeDetection', { clear = true }) -vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { - pattern = { 'docker-compose.yaml', 'compose.yaml' }, - command = 'set filetype=yaml.docker-compose', - -- group = 'DockerFileTypeDetection', -}) +local function DockerFileTypeDetectionAutoCommand() + local names = { 'docker-compose', 'compose' } + local extensions = { '.yaml', '.yml' } + local tbl = {} + local i = 1 + + for _, name in pairs(names) do + for _, ext in pairs(extensions) do + tbl[i] = name .. ext + i = i + 1 + end + end + + -- vim.api.nvim_create_augroup('DockerFileTypeDetection', { clear = true }) + vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { + pattern = tbl, + command = 'set filetype=yaml.docker-compose', + -- group = 'DockerFileTypeDetection', + }) +end + +DockerFileTypeDetectionAutoCommand() -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info From 24ec529102e1a5f1ff32c5cbfb1b8b12cd3df933 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Thu, 29 Aug 2024 12:21:33 +0200 Subject: [PATCH 25/41] Configure LSPs via Languages and Profiles --- lua/kickstart/plugins/lsp.lua | 152 +++------------------------------- lua/utils/languages.lua | 109 ++++++++++++++++++++++++ lua/utils/profile.lua | 27 ++++++ 3 files changed, 148 insertions(+), 140 deletions(-) create mode 100644 lua/utils/languages.lua create mode 100644 lua/utils/profile.lua diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 62a8fd453e6..e9696f537bc 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -206,119 +206,6 @@ return { 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 = {}, - pyright = { - settings = { - python = { - analysis = { - autoSearchPaths = true, - diagnosticMode = 'workspace', - useLibraryCodeForTypes = true, - autoImportCompletions = true, - }, - }, - }, - disableLanguageServices = false, - }, - basedpyright = { - settings = { - basedpyright = { - analysis = { - autoSearchPaths = true, - typeCheckingMode = 'basic', - diagnosticMode = 'openFilesOnly', - useLibraryCodeForTypes = true, - }, - }, - }, - }, - gopls = { - settings = { - gopls = { - analyses = { - unusedparams = true, - }, - staticcheck = true, - hints = { - rangeVariableTypes = true, - parameterNames = true, - constantValues = true, - assignVariableTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - functionTypeParameters = true, - }, - gofumpt = true, - }, - }, - }, - -- pylsp = { - -- settings = { - -- pylsp = { - -- plugins = { - -- pycodestyle = { - -- ignore = {}, - -- maxLineLength = 120, - -- }, - -- }, - -- } - -- } - -- }, - rust_analyzer = { - alias = 'rust-analyzer', - }, - - markdown_oxide = { - alias = 'markdown-oxide', - }, - -- ... 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 = {}, - -- - nixd = {}, - ['nil_ls'] = { - alias = 'nil', - }, - bashls = { - alias = 'bash-language-server', - }, - dockerls = { - alias = 'docker-langserver', - }, - docker_compose_language_service = { - alias = 'docker-compose-langserver', - }, - lua_ls = { - -- cmd = {...}, - -- filetypes = { ...}, - -- capabilities = {}, - alias = 'lua-language-server', - 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 @@ -329,39 +216,24 @@ return { -- 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 } -- INFO: Using my own utils function instead of mason-lspconfig as it checks if the stuff is already installed -- outside of mason. This is useful for NixOS setup where mason version just doesn't work sometimes due to libc issues. - local installed = {} - local i = 0 - for server, config in pairs(servers) do - if config.alias then - installed[i] = config.alias - else - installed[i] = server + + -- We take the languages configured for a given profile + -- Given the profile we take the LSPs configured for the languages + -- Then we guarantee use or install the LSPs + local languages = require('utils.profile').Languages() + local languageServers = require 'utils.languages' + local tmpTable = {} + for _, lang in ipairs(languages) do + for lsp, config in pairs(languageServers[lang]) do + tmpTable[lsp] = config end - i = i + 1 end - table.insert(installed, 'stylua') - require('utils.mason').install(installed, true) - -- require('utils.mason').install { - -- -- "python-lsp-server", - -- 'pyright', - -- 'basedpyright', - -- 'bash-language-server', - -- -- "rnix-lsp", - -- 'lua-language-server', - -- -- "docker-compose-language-service", - -- -- "nil", - -- } - + require('utils.mason').install(tmpTable, true) local lsp = require 'lspconfig' - - for server, config in pairs(servers) do + for server, config in pairs(tmpTable) do config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) config.on_attach = on_attach lsp[server].setup(config) diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua new file mode 100644 index 00000000000..71f152fe3a8 --- /dev/null +++ b/lua/utils/languages.lua @@ -0,0 +1,109 @@ +-- 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 Languages = { + ['python'] = { + pyright = { + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'workspace', + useLibraryCodeForTypes = true, + autoImportCompletions = true, + }, + }, + }, + disableLanguageServices = false, + }, + basedpyright = { + settings = { + basedpyright = { + analysis = { + autoSearchPaths = true, + typeCheckingMode = 'basic', + diagnosticMode = 'openFilesOnly', + useLibraryCodeForTypes = true, + }, + }, + }, + }, + }, + ['go'] = { + gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + hints = { + rangeVariableTypes = true, + parameterNames = true, + constantValues = true, + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + functionTypeParameters = true, + }, + gofumpt = true, + }, + }, + }, + }, + ['rust'] = { + rust_analyzer = { + alias = 'rust-analyzer', + }, + }, + ['markdown'] = { + markdown_oxide = { + alias = 'markdown-oxide', + }, + }, + ['nix'] = { + nixd = {}, + ['nil_ls'] = { + alias = 'nil', + }, + }, + ['bash'] = { + bashls = { + alias = 'bash-language-server', + }, + }, + ['docker'] = { + dockerls = { + alias = 'docker-langserver', + }, + docker_compose_language_service = { + alias = 'docker-compose-langserver', + }, + }, + ['lua'] = { + lua_ls = { + -- cmd = {...}, + -- filetypes = { ...}, + -- capabilities = {}, + alias = 'lua-language-server', + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + stylua = nil, + }, +} + +return Languages diff --git a/lua/utils/profile.lua b/lua/utils/profile.lua new file mode 100644 index 00000000000..a92ffcf7086 --- /dev/null +++ b/lua/utils/profile.lua @@ -0,0 +1,27 @@ +local PROFILES = { + ['HOME'] = { + 'python', + 'nix', + 'go', + 'rust', + 'markdown', + 'bash', + 'docker', + 'lua', + }, + ['DEFAULT'] = { + 'python', + 'markdown', + 'bash', + 'docker', + 'lua', + }, +} + +local Profile = {} +Profile.Languages = function() + local profile = PROFILES[os.getenv 'NVIM_PROFILE' or 'DEFAULT'] + return profile +end + +return Profile From 84e58e64bc2cdbbb0704337d01e103621a627aad Mon Sep 17 00:00:00 2001 From: peturparkur Date: Fri, 30 May 2025 23:40:03 +0200 Subject: [PATCH 26/41] nixd additional configuration --- lua/utils/languages.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index 71f152fe3a8..b3a9e806778 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -68,10 +68,29 @@ local Languages = { }, }, ['nix'] = { - nixd = {}, - ['nil_ls'] = { - alias = 'nil', + nixd = { + settings = { + nixd = { + nixpkgs = { + expr = 'import { }', + }, + formatting = { + command = { 'nixfmt' }, + }, + options = { + nixos = { + expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.k-on.options', + }, + home_manager = { + expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options', + }, + }, + }, + }, }, + -- ['nil_ls'] = { + -- alias = 'nil', + -- }, }, ['bash'] = { bashls = { From 4e5abb3d444791e947112719ba4b38c2c4e1f4ad Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 17 Jun 2025 21:36:19 +0200 Subject: [PATCH 27/41] add nil and formatting --- lua/kickstart/plugins/treesitter.lua | 57 ++++++++++++++-------------- lua/utils/languages.lua | 6 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index 3cec8768c82..636c71070ee 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -1,32 +1,33 @@ return { -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - opts = { - ensure_installed = { 'bash', 'c', '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' } }, + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + opts = { + ensure_installed = { 'bash', 'c', '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' }, }, - config = function(_, opts) - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + 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) + -- 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 - end, -} \ No newline at end of file diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index b3a9e806778..bdb66f5168b 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -88,9 +88,9 @@ local Languages = { }, }, }, - -- ['nil_ls'] = { - -- alias = 'nil', - -- }, + ['nil_ls'] = { + alias = 'nil', + }, }, ['bash'] = { bashls = { From ffb4ed4b4f924a10ef52a12296545eb02e7ac8f4 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 24 Jun 2025 20:21:16 +0200 Subject: [PATCH 28/41] update which-key spec --- lua/kickstart/plugins/whichkey.lua | 96 ++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/lua/kickstart/plugins/whichkey.lua b/lua/kickstart/plugins/whichkey.lua index aa5f6bbc067..02d472fa0a4 100644 --- a/lua/kickstart/plugins/whichkey.lua +++ b/lua/kickstart/plugins/whichkey.lua @@ -1,37 +1,67 @@ -- 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 +-- +-- 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 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() + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + 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 which-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 = '', + }, + }, - -- 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, -} \ No newline at end of file + -- Document existing key chains + spec = { + { 's', group = '[S]earch' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + }, + }, +} From ffda44e39cdeaa8238d83a134eda609cca80bef7 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 24 Jun 2025 21:09:07 +0200 Subject: [PATCH 29/41] update lsp configuration + enable debug --- init.lua | 5 +- lua/kickstart/plugins/debug.lua | 88 ++++++++++++++++++++++++------ lua/kickstart/plugins/lint.lua | 4 +- lua/kickstart/plugins/lsp.lua | 95 +++++++++++++++++++++++++-------- 4 files changed, 152 insertions(+), 40 deletions(-) diff --git a/init.lua b/init.lua index 20f471fa5d1..b2b33b93155 100644 --- a/init.lua +++ b/init.lua @@ -356,13 +356,16 @@ require('lazy').setup({ -- 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', require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + -- Allows extra capabilities provided by blink.cmp + 'saghen/blink.cmp', + -- 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. -- diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 7be4abdbd96..8e332bf2ff9 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -18,12 +18,65 @@ return { 'nvim-neotest/nvim-nio', -- Installs the debug adapters for you - 'williamboman/mason.nvim', + 'mason-org/mason.nvim', 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here 'leoluz/nvim-dap-go', }, + 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' @@ -31,7 +84,7 @@ return { require('mason-nvim-dap').setup { -- Makes a best effort to setup the various debuggers with -- reasonable debug configurations - automatic_setup = true, + automatic_installation = true, -- You can provide additional configuration to the handlers, -- see mason-nvim-dap README for more information @@ -45,16 +98,6 @@ return { }, } - -- 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' }) - 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 { @@ -77,14 +120,29 @@ 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.' }) + -- Change breakpoint icons + -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) + -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) + -- local breakpoint_icons = vim.g.have_nerd_font + -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } + -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } + -- for type, icon in pairs(breakpoint_icons) do + -- local tp = 'Dap' .. type + -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' + -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + -- end dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close -- Install golang specific config - require('dap-go').setup() + 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/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 7f0dc42fbbf..c90cafd444f 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -11,8 +11,8 @@ return { -- To allow other plugins to add linters to require('lint').linters_by_ft, -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } + lint.linters_by_ft = lint.linters_by_ft or {} + lint.linters_by_ft['markdown'] = { 'markdownlint' } -- -- However, note that this will enable a set of default linters, -- which will cause errors unless these tools are available: diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index e9696f537bc..55de5c716a7 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -1,4 +1,17 @@ return { + -- LSP 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 = '${3rd}/luv/library', words = { 'vim%.uv' } }, + }, + }, + }, { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', @@ -11,10 +24,9 @@ return { -- 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 = {} }, + -- + -- Allows extra capabilities provided by blink.cmp + 'saghen/blink.cmp', }, config = function() -- some default parameters @@ -154,8 +166,21 @@ return { -- See `:help CursorHold` for information about when this is executed -- -- When you move your cursor, the highlights will be cleared (the second autocommand). + ---- 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 + 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(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, @@ -168,20 +193,20 @@ return { 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 - local function dump_table(tbl) - local result = '' - for k, v in pairs(tbl) do - result = result .. (k .. ': ' .. tostring(v)) .. ',\t' - end - return string.sub(result, 1, -2) - end - vim.lsp.inlay_hint.enable(true) if client and client.server_capabilities.inlayHintProvider then map('th', function() @@ -191,20 +216,46 @@ return { end, }) - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf } - 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 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() -- 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()) + -- local capabilities = vim.lsp.protocol.make_client_capabilities() + -- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install From dcb979b9c85c58200336f44c7c129699bac7d85c Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 24 Jun 2025 21:11:35 +0200 Subject: [PATCH 30/41] add blink.cmp --- init.lua | 3 -- lua/kickstart/plugins/lsp.lua | 99 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index b2b33b93155..8bf0ebe1f95 100644 --- a/init.lua +++ b/init.lua @@ -363,9 +363,6 @@ require('lazy').setup({ require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps - -- Allows extra capabilities provided by blink.cmp - 'saghen/blink.cmp', - -- 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. -- diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 55de5c716a7..8b7ca56d21e 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -323,4 +323,103 @@ return { require('lsp_signature').setup(opts) end, }, + + { -- Autocompletion + 'saghen/blink.cmp', + event = 'VimEnter', + version = '1.*', + dependencies = { + -- Snippet Engine + { + 'L3MON4D3/LuaSnip', + version = '2.*', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + opts = {}, + }, + 'folke/lazydev.nvim', + }, + --- @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! + -- + -- 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', + }, + + 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 = { + default = { 'lsp', 'path', 'snippets', 'lazydev' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + }, + }, + + 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 }, + }, + }, } From 5d01f03eda5dab278a2475e895f0292107d43e88 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 24 Jun 2025 21:14:56 +0200 Subject: [PATCH 31/41] disable treesitter indentation + comments --- init.lua | 1 + lua/kickstart/plugins/treesitter.lua | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 8bf0ebe1f95..227c077c48f 100644 --- a/init.lua +++ b/init.lua @@ -217,6 +217,7 @@ local function DockerFileTypeDetectionAutoCommand() end end + -- Hacky way to configure correct filetype for docker-compose LSP -- vim.api.nvim_create_augroup('DockerFileTypeDetection', { clear = true }) vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { pattern = tbl, diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index 636c71070ee..bbc032a4290 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -12,7 +12,7 @@ return { -- Highlight, edit, and navigate code -- the list of additional_vim_regex_highlighting and disabled languages for indent. additional_vim_regex_highlighting = { 'ruby' }, }, - indent = { enable = true, disable = { 'ruby' } }, + -- indent = { enable = true, disable = { 'ruby' } }, }, config = function(_, opts) -- [[ Configure Treesitter ]] See `:help nvim-treesitter` @@ -30,4 +30,3 @@ return { -- Highlight, edit, and navigate code -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects end, } - From 4a68e9323e9a9a111371d580d71d426a8ac48958 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 24 Jun 2025 21:33:35 +0200 Subject: [PATCH 32/41] swap nix language server order --- lua/utils/languages.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index bdb66f5168b..e49edb64ba8 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -68,6 +68,9 @@ local Languages = { }, }, ['nix'] = { + ['nil_ls'] = { + alias = 'nil', + }, nixd = { settings = { nixd = { @@ -79,7 +82,8 @@ local Languages = { }, options = { nixos = { - expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.k-on.options', + expr = '(builtins.getFlake "/home/peter/nodes/nixos-minipc").nixosConfigurations.peter-laptop.options', + -- expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.k-on.options', }, home_manager = { expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options', @@ -88,9 +92,6 @@ local Languages = { }, }, }, - ['nil_ls'] = { - alias = 'nil', - }, }, ['bash'] = { bashls = { From 3807d7d2357195b112c9c076239a4907c3824fbb Mon Sep 17 00:00:00 2001 From: peturparkur Date: Tue, 24 Jun 2025 21:41:44 +0200 Subject: [PATCH 33/41] configure nix to my configuration --- lua/utils/languages.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index e49edb64ba8..1cf829e7331 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -83,10 +83,9 @@ local Languages = { options = { nixos = { expr = '(builtins.getFlake "/home/peter/nodes/nixos-minipc").nixosConfigurations.peter-laptop.options', - -- expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.k-on.options', }, home_manager = { - expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."ruixi@k-on".options', + expr = '(builtins.getFlake "/home/peter/nodes/nixos-minipc").nixosConfigurations.peter@peter-laptop.options', }, }, }, From 115243d39565bed7b5b47f12fbec41d17a913840 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Sat, 2 Aug 2025 11:24:28 +0200 Subject: [PATCH 34/41] python formatting --- init.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/init.lua b/init.lua index 227c077c48f..65f5ab78ebd 100644 --- a/init.lua +++ b/init.lua @@ -331,6 +331,23 @@ require('lazy').setup({ lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, + python = { + 'ruff_fix', + 'ruff_organize_imports', + ruff_format = { + args = function(_, _) + return { + 'format', + '--force-exclude', + '--line-length', + '120', + '--stdin-filename', + '$FILENAME', + '-', + } + end, + }, + }, -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. From 2985d9868400ccc07cea8ad78d28af35cad61271 Mon Sep 17 00:00:00 2001 From: peturparkur <61064454+peturparkur@users.noreply.github.com> Date: Sun, 3 Aug 2025 18:23:21 +0200 Subject: [PATCH 35/41] Beta (#4) * remove doc/tags * use cmd instead of alias for clarity * use alias and proper checking of existing command installation * mason pkg name override * we still want to enforce local by default * remove unused on_attach since we have event to control it * fallback to using existing docker language servers * add yaml language server + remove table setup logging * write comment what symbol we expect * more notes * use mason-lspconfig for getting lsp->mason map and better utilities * use very lazy --- doc/tags | 3 - init.lua | 14 +++- lua/kickstart/plugins/lsp.lua | 110 ++++++++---------------------- lua/utils/languages.lua | 25 +++++++ lua/utils/mappings/lsp_to_cmd.lua | 1 + lua/utils/mason.lua | 44 +++++++----- lua/utils/profile.lua | 23 ++++++- 7 files changed, 113 insertions(+), 107 deletions(-) delete mode 100644 doc/tags create mode 100644 lua/utils/mappings/lsp_to_cmd.lua 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/init.lua b/init.lua index 65f5ab78ebd..8557b3ced68 100644 --- a/init.lua +++ b/init.lua @@ -226,7 +226,19 @@ local function DockerFileTypeDetectionAutoCommand() }) end -DockerFileTypeDetectionAutoCommand() +local function AddDockerFilesToFiletype() + vim.filetype.add { + filename = { + ['docker-compose.yml'] = 'yaml.docker-compose', + ['docker-compose.yaml'] = 'yaml.docker-compose', + ['compose.yml'] = 'yaml.docker-compose', + ['compose.yaml'] = 'yaml.docker-compose', + }, + } +end + +-- DockerFileTypeDetectionAutoCommand() +AddDockerFilesToFiletype() -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 8b7ca56d21e..0a653249361 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -17,8 +17,8 @@ return { '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', + { 'mason-org/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants + 'mason-org/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Useful status updates for LSP. @@ -61,52 +61,6 @@ return { -- 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 - local on_attach = function(_, buffr) - local kset = function(key, func, buffer, desc) - vim.keymap.set('n', key, func, { buffer = buffer, 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 . - kset('gd', require('telescope.builtin').lsp_definitions, buffr, '[G]oto [D]efinition') - - -- Find references for the word under your cursor. - kset('gr', require('telescope.builtin').lsp_references, buffr, '[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. - kset('gI', require('telescope.builtin').lsp_implementations, buffr, '[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*. - kset('D', require('telescope.builtin').lsp_type_definitions, buffr, 'Type [D]efinition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - kset('ds', require('telescope.builtin').lsp_document_symbols, buffr, '[D]ocument [S]ymbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - kset('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, buffr, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - kset('rn', vim.lsp.buf.rename, buffr, '[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. - kset('ca', vim.lsp.buf.code_action, buffr, '[C]ode [A]ction') - - -- Opens a popup that displays documentation about the word under your cursor - -- See `:help K` for why this keymap. - kset('K', vim.lsp.buf.hover, buffr, 'Hover Documentation') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - kset('gD', vim.lsp.buf.declaration, buffr, '[G]oto [D]eclaration') - end vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), @@ -222,14 +176,16 @@ return { 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 {}, + signs = vim.g.have_nerd_font + and { + text = { + [vim.diagnostic.severity.ERROR] = '󰅚 ', -- circle with cross + [vim.diagnostic.severity.WARN] = '󰀪 ', -- triangle warning + [vim.diagnostic.severity.INFO] = '󰋽 ', -- circle with i + [vim.diagnostic.severity.HINT] = '󰌶 ', -- lightbulb + }, + } + or {}, virtual_text = { source = 'if_many', spacing = 2, @@ -268,40 +224,28 @@ return { -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. -- require('mason-tool-installer').setup { ensure_installed = ensure_installed } + -- INFO: Using my own utils function instead of mason-lspconfig as it checks if the stuff is already installed -- outside of mason. This is useful for NixOS setup where mason version just doesn't work sometimes due to libc issues. - -- We take the languages configured for a given profile -- Given the profile we take the LSPs configured for the languages -- Then we guarantee use or install the LSPs - local languages = require('utils.profile').Languages() - local languageServers = require 'utils.languages' - local tmpTable = {} - for _, lang in ipairs(languages) do - for lsp, config in pairs(languageServers[lang]) do - tmpTable[lsp] = config - end - end - require('utils.mason').install(tmpTable, true) - local lsp = require 'lspconfig' - for server, config in pairs(tmpTable) do + local lsps = require('utils.profile').LanguageServers() + -- print(vim.inspect(lsps)) + local missing_lsps = require('utils.mason').missing(lsps) -- find missing lsps + -- print(vim.inspect(missing_lsps)) + missing_lsps = {} -- TODO: this is only for NixOS to prefer installing via nixpkgs instead of mason + + -- install the executables of the language servers that we don't already have installed locally outside of mason + require('utils.mason').install(missing_lsps) + + -- configure nvim lsp via lspconfig package for our list of lsps + local lspconfig = require 'lspconfig' + for server, config in pairs(lsps) do config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) - config.on_attach = on_attach - lsp[server].setup(config) + -- config.on_attach = on_attach -- we don't need this because of the events + lspconfig[server].setup(config) end - - -- 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, }, -- Show LSP explorer of functions and classes etc. diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index 1cf829e7331..68d503f6bef 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -105,6 +105,31 @@ local Languages = { alias = 'docker-compose-langserver', }, }, + ['yaml'] = { + yamlls = { + alias = 'yaml-language-server', + settings = { + yaml = { + schemas = { + extra = { + -- kubernetes = 'k8s-*.yaml', -- TODO: consider using *.k8s.yaml for kubernetes schemas + ['http://json.schemastore.org/github-workflow'] = '.github/workflows/*', + ['http://json.schemastore.org/github-action'] = '.github/action.{yml,yaml}', + ['http://json.schemastore.org/ansible-stable-2.9'] = 'roles/tasks/**/*.{yml,yaml}', + ['http://json.schemastore.org/prettierrc'] = '.prettierrc.{yml,yaml}', + ['http://json.schemastore.org/kustomization'] = 'kustomization.{yml,yaml}', + ['http://json.schemastore.org/chart'] = 'Chart.{yml,yaml}', + ['http://json.schemastore.org/circleciconfig'] = '.circleci/**/*.{yml,yaml}', + }, + }, + format = { + enable = true, + }, + redhat = { telemetry = { enabled = false } }, + }, + }, + }, + }, ['lua'] = { lua_ls = { -- cmd = {...}, diff --git a/lua/utils/mappings/lsp_to_cmd.lua b/lua/utils/mappings/lsp_to_cmd.lua new file mode 100644 index 00000000000..285db91713e --- /dev/null +++ b/lua/utils/mappings/lsp_to_cmd.lua @@ -0,0 +1 @@ +-- TODO: move lsp_config_name -> executable mapping here instead of being part of languages.lua file diff --git a/lua/utils/mason.lua b/lua/utils/mason.lua index 4ad6c2a8aad..321f62be29e 100644 --- a/lua/utils/mason.lua +++ b/lua/utils/mason.lua @@ -7,33 +7,43 @@ local name_to_bin = { -- ['docker-compose-language-service'] = 'docker-compose-langserver', } --- We guarantee 'ensure_installed' package is installed locally --- If enforce_local is false then we install it via mason-registry --- By default we install LSPs via mason -M.install = function(ensure_installed, enforce_local) - -- Allow for passing in a single string +M.missing = function(ensure_installed) if type(ensure_installed) == 'string' then ensure_installed = { ensure_installed } end - enforce_local = enforce_local == nil and false or enforce_local + local result = {} + for lsp_name, config in pairs(ensure_installed) do + local executable_name = lsp_name + if config['alias'] then + executable_name = config['alias'] + end - -- Function to check if the executable exists in the PATH - local function executable_exists(name) - if name_to_bin[name] then - return vim.fn.executable(name_to_bin[name]) == 1 + -- check if executable exists + if vim.fn.executable(executable_name) ~= 1 then + result[lsp_name] = config end - return vim.fn.executable(name) == 1 end + return result +end + +-- We guarantee 'ensure_installed' package is installed locally +-- If enforce_local is false then we install it via mason-registry +-- By default we install LSPs via mason +M.install = function(ensure_installed) + -- ensure installed is expected of the form : {cmd: "", settings: {...}} + + -- ensure_installed = M.missing(ensure_installed, enforce_local) + local lspconfig_to_pkg = require('mason-lspconfig').get_mappings().lspconfig_to_package local registry = require 'mason-registry' + -- local mason_lspconfig = require 'mason-lspconfig' registry.refresh(function() - for _, pkg_name in ipairs(ensure_installed) do - if (not executable_exists(pkg_name)) and not enforce_local then - local pkg = registry.get_package(pkg_name) - if not pkg:is_installed() then - pkg:install() - end + for lsp_cfg, _ in pairs(ensure_installed) do + local pkg_name = lspconfig_to_pkg[lsp_cfg] -- get mason package name based on lspconfig name + local pkg = registry.get_package(pkg_name) + if not pkg:is_installed() then + pkg:install() end end end) diff --git a/lua/utils/profile.lua b/lua/utils/profile.lua index a92ffcf7086..edaad0fcfa7 100644 --- a/lua/utils/profile.lua +++ b/lua/utils/profile.lua @@ -8,6 +8,7 @@ local PROFILES = { 'bash', 'docker', 'lua', + 'yaml', }, ['DEFAULT'] = { 'python', @@ -15,13 +16,29 @@ local PROFILES = { 'bash', 'docker', 'lua', + 'yaml', }, } local Profile = {} -Profile.Languages = function() - local profile = PROFILES[os.getenv 'NVIM_PROFILE' or 'DEFAULT'] - return profile +Profile.Languages = function(profile) + if profile == nil then + profile = os.getenv 'NVIM_PROFILE' or 'DEFAULT' + end + return PROFILES[profile] +end + +Profile.LanguageServers = function(profile) + local languages = Profile.Languages(profile) + local language_config = require 'utils.languages' + + local result = {} -- -> {} + for _, lang in ipairs(languages) do + for lsp, config in pairs(language_config[lang]) do + result[lsp] = config + end + end + return result end return Profile From 14573da6df0b221d5d0f86adbd4c896ce4b6f5da Mon Sep 17 00:00:00 2001 From: peturparkur <61064454+peturparkur@users.noreply.github.com> Date: Sun, 3 Aug 2025 18:35:57 +0200 Subject: [PATCH 36/41] remove telescope version branch + format (#5) * remove telescope version branch + format * more formatting --- lua/kickstart/plugins/autocomplete.lua | 199 +++++++++++++------------ lua/kickstart/plugins/mini.lua | 65 ++++---- lua/kickstart/plugins/telescope.lua | 197 ++++++++++++------------ 3 files changed, 232 insertions(+), 229 deletions(-) diff --git a/lua/kickstart/plugins/autocomplete.lua b/lua/kickstart/plugins/autocomplete.lua index e9d05724fea..53026f6f4fc 100644 --- a/lua/kickstart/plugins/autocomplete.lua +++ b/lua/kickstart/plugins/autocomplete.lua @@ -1,110 +1,111 @@ return { -- 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, - -- }, - }, + '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 {} + 'saadparwaiz1/cmp_luasnip', - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, + -- 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 {} - -- 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(), + 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), + -- 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 }, + -- 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(), + -- 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 {}, + -- 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' }), + -- 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, +} - -- 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, -} \ No newline at end of file diff --git a/lua/kickstart/plugins/mini.lua b/lua/kickstart/plugins/mini.lua index a7439e4b290..7605cf9d597 100644 --- a/lua/kickstart/plugins/mini.lua +++ b/lua/kickstart/plugins/mini.lua @@ -1,37 +1,38 @@ return { -- 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 } + '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() + -- 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 } + -- 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 + -- 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, +} - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, -} \ No newline at end of file diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua index a2eba371e12..9839b55df2d 100644 --- a/lua/kickstart/plugins/telescope.lua +++ b/lua/kickstart/plugins/telescope.lua @@ -1,111 +1,112 @@ -- 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 +-- +-- 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 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', + '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', + -- `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 }, + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, }, - 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! + { 'nvim-telescope/telescope-ui-select.nvim' }, - -- [[ 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(), - }, + -- 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') - -- 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' }) - -- 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' }) - -- 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' }) - -- 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, +} - -- 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, -} \ No newline at end of file From 2fa0eab1a7afde15908d083bfd6c92859806015a Mon Sep 17 00:00:00 2001 From: peturparkur <61064454+peturparkur@users.noreply.github.com> Date: Sun, 3 Aug 2025 22:29:26 +0200 Subject: [PATCH 37/41] configure yamlls for kubernetes resources with extension .k8s.yaml (#6) --- lua/utils/languages.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index 68d503f6bef..2ba4e0f3cc7 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -111,8 +111,8 @@ local Languages = { settings = { yaml = { schemas = { + kubernetes = '*.k8s.yaml', -- TODO: consider using *.k8s.yaml for kubernetes schemas extra = { - -- kubernetes = 'k8s-*.yaml', -- TODO: consider using *.k8s.yaml for kubernetes schemas ['http://json.schemastore.org/github-workflow'] = '.github/workflows/*', ['http://json.schemastore.org/github-action'] = '.github/action.{yml,yaml}', ['http://json.schemastore.org/ansible-stable-2.9'] = 'roles/tasks/**/*.{yml,yaml}', From c3c0b45e6e6b03dfa045e5483aa78223f9713bb1 Mon Sep 17 00:00:00 2001 From: peturparkur <61064454+peturparkur@users.noreply.github.com> Date: Sun, 17 Aug 2025 21:20:47 +0200 Subject: [PATCH 38/41] finally no double autocomplete (#7) --- init.lua | 20 +++- .../plugins/autocomplete/blink-cmp.lua | 98 +++++++++++++++++ .../nvim-cmp.lua} | 1 - lua/kickstart/plugins/lsp.lua | 103 +----------------- lua/utils/languages.lua | 8 ++ 5 files changed, 122 insertions(+), 108 deletions(-) create mode 100644 lua/kickstart/plugins/autocomplete/blink-cmp.lua rename lua/kickstart/plugins/{autocomplete.lua => autocomplete/nvim-cmp.lua} (99%) diff --git a/init.lua b/init.lua index 8557b3ced68..daf85fe3940 100644 --- a/init.lua +++ b/init.lua @@ -316,7 +316,8 @@ require('lazy').setup({ require 'kickstart.plugins.lsp', { -- Autoformat 'stevearc/conform.nvim', - lazy = false, + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, keys = { { 'f', @@ -334,10 +335,14 @@ 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, cpp = true } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } + if disable_filetypes[vim.bo[bufnr].filetype] then + return nil + else + return { + timeout_ms = 500, + lsp_format = 'fallback', + } + end end, formatters_by_ft = { lua = { 'stylua' }, @@ -368,7 +373,10 @@ require('lazy').setup({ }, }, - require 'kickstart.plugins.autocomplete', + -- autocomplete/autocompletion engines + -- require 'kickstart.plugins.autocomplete.blink-cmp', + require 'kickstart.plugins.autocomplete.nvim-cmp', + -- THEMES -- require 'kickstart.plugins.themes.tokyonight', require 'kickstart.plugins.themes.catppuccin', diff --git a/lua/kickstart/plugins/autocomplete/blink-cmp.lua b/lua/kickstart/plugins/autocomplete/blink-cmp.lua new file mode 100644 index 00000000000..fbbac008150 --- /dev/null +++ b/lua/kickstart/plugins/autocomplete/blink-cmp.lua @@ -0,0 +1,98 @@ +return { -- Autocompletion + 'saghen/blink.cmp', + event = 'VimEnter', + version = '1.*', + dependencies = { + -- Snippet Engine + { + 'L3MON4D3/LuaSnip', + version = '2.*', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + opts = {}, + }, + 'folke/lazydev.nvim', + }, + --- @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! + -- + -- 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', + }, + + 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 = { + default = { 'lsp', 'path', 'snippets', 'lazydev' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + }, + }, + + 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 }, + }, +} diff --git a/lua/kickstart/plugins/autocomplete.lua b/lua/kickstart/plugins/autocomplete/nvim-cmp.lua similarity index 99% rename from lua/kickstart/plugins/autocomplete.lua rename to lua/kickstart/plugins/autocomplete/nvim-cmp.lua index 53026f6f4fc..71e6c6ddb41 100644 --- a/lua/kickstart/plugins/autocomplete.lua +++ b/lua/kickstart/plugins/autocomplete/nvim-cmp.lua @@ -108,4 +108,3 @@ return { -- Autocompletion } end, } - diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 0a653249361..2a9bfab3d29 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -162,9 +162,9 @@ return { -- -- This may be unwanted, since they displace some of your code vim.lsp.inlay_hint.enable(true) - if client and client.server_capabilities.inlayHintProvider then + 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()) + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end end, @@ -267,103 +267,4 @@ return { require('lsp_signature').setup(opts) end, }, - - { -- Autocompletion - 'saghen/blink.cmp', - event = 'VimEnter', - version = '1.*', - dependencies = { - -- Snippet Engine - { - 'L3MON4D3/LuaSnip', - version = '2.*', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - -- `friendly-snippets` contains a variety of premade snippets. - -- See the README about individual language/framework/plugin snippets: - -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, - }, - opts = {}, - }, - 'folke/lazydev.nvim', - }, - --- @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! - -- - -- 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', - }, - - 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 = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, - providers = { - lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, - }, - }, - - 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 }, - }, - }, } diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index 2ba4e0f3cc7..341d64f9676 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -23,6 +23,14 @@ local Languages = { disableLanguageServices = false, }, basedpyright = { + capabilities = { + -- Basedpyright does not support these capabilities well. + definitionProvider = false, + typeDefinitionProvider = false, + implementationProvider = false, + referencesProvider = false, + -- hoverProvider = false, -- decide if pyright or basedpyright + }, settings = { basedpyright = { analysis = { From d1aade11b5d39ebfe9c54e28e2323d92dcc79d38 Mon Sep 17 00:00:00 2001 From: peturparkur <61064454+peturparkur@users.noreply.github.com> Date: Mon, 25 Aug 2025 20:55:30 +0200 Subject: [PATCH 39/41] almost no-op (#8) * add folding * no more fold --- lua/kickstart/plugins/lsp.lua | 5 +++++ lua/kickstart/plugins/treesitter.lua | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 2a9bfab3d29..3ae4bf3b68a 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -167,6 +167,11 @@ return { vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end + + if client and client_supports_method(client, 'textDocument/foldingRange', event.buf) then + -- local win = vim.api.nvim_get_current_win() + -- vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()' + end end, }) diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index bbc032a4290..d37a3565dfe 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -15,6 +15,15 @@ return { -- Highlight, edit, and navigate code -- indent = { enable = true, disable = { 'ruby' } }, }, config = function(_, opts) + -- fold method to be function / treesitter + -- vim.o.foldmethod = 'expr' + -- Default to treesitter folding + -- vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()' + -- vim.o.foldenable = false + vim.opt.foldnestmax = 4 + vim.opt.foldlevel = 99 + vim.opt.foldlevelstart = 1 + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` -- Prefer git instead of curl in order to improve connectivity in some environments From 57c0b6c568779674b84c6318c23f6fdba93650cc Mon Sep 17 00:00:00 2001 From: peturparkur Date: Mon, 25 Aug 2025 21:21:01 +0200 Subject: [PATCH 40/41] new notation for setting up LSPs --- lua/kickstart/plugins/lsp.lua | 17 +++++++++++------ lua/utils/languages.lua | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 3ae4bf3b68a..d65c5fd3da9 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -210,13 +210,13 @@ return { -- By default, Neovim doesn't support everything that is in the LSP specification. -- 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() + -- local capabilities = require('blink.cmp').get_lsp_capabilities() -- 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()) + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install @@ -245,11 +245,16 @@ return { require('utils.mason').install(missing_lsps) -- configure nvim lsp via lspconfig package for our list of lsps - local lspconfig = require 'lspconfig' + -- local lspconfig = require 'lspconfig' for server, config in pairs(lsps) do + -- tbl_deep_extend with force -> on conflict use value from right config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) - -- config.on_attach = on_attach -- we don't need this because of the events - lspconfig[server].setup(config) + + -- the require(lspconfig)[server].setup({...}) notation is deprecated in nvim-lspconfig + -- Thus we use the new notation for setting up LSPs + -- Part below is equivalent to require('lspconfig')[server].setup(config) + vim.lsp.config(server, config) + vim.lsp.enable(server) end end, }, diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index 341d64f9676..d66bde1a49e 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -9,6 +9,7 @@ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local Languages = { ['python'] = { + pyrefly = {}, pyright = { settings = { python = { From 20385b22e9563ea44f419f58c631c8250e54cd20 Mon Sep 17 00:00:00 2001 From: peturparkur Date: Mon, 25 Aug 2025 22:16:01 +0200 Subject: [PATCH 41/41] add hinting to lua --- lua/utils/languages.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index d66bde1a49e..399a5b414ef 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -150,6 +150,9 @@ local Languages = { completion = { callSnippet = 'Replace', }, + hint = { + enable = true, + }, -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- diagnostics = { disable = { 'missing-fields' } }, },