From 51b1a17ea8b026765fcdd7ba8e3bb642c98453ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levente=20Krizs=C3=A1n?= Date: Tue, 27 Aug 2024 21:35:31 +0200 Subject: [PATCH] Add a few custom plugins and mappings --- init.lua | 49 ++++++++++++++++++++-------- lua/custom/plugins/lsp-signature.lua | 10 ++++++ lua/custom/plugins/noice.lua | 39 ++++++++++++++++++++++ lua/custom/plugins/tag-autoclose.lua | 6 ++++ lua/custom/plugins/tmux.lua | 18 ++++++++++ lua/custom/plugins/ts-comments.lua | 6 ++++ 6 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 lua/custom/plugins/lsp-signature.lua create mode 100644 lua/custom/plugins/noice.lua create mode 100644 lua/custom/plugins/tag-autoclose.lua create mode 100644 lua/custom/plugins/tmux.lua create mode 100644 lua/custom/plugins/ts-comments.lua diff --git a/init.lua b/init.lua index 13c8143d..a4e01b71 100644 --- a/init.lua +++ b/init.lua @@ -190,6 +190,9 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +vim.keymap.set('n', 'v', ':vsplit', { noremap = true, silent = true, desc = 'Create vertical split' }) +vim.keymap.set('n', 'h', ':split', { noremap = true, silent = true, desc = 'Create horizontal split' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -608,14 +611,28 @@ require('lazy').setup({ -- clangd = {}, -- gopls = {}, -- pyright = {}, - -- rust_analyzer = {}, + 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 = {}, + tsserver = { + -- https://github.com/neovim/nvim-lspconfig/issues/2688#issuecomment-1601582648 + init_options = { + preferences = { + includeInlayParameterNameHints = 'all', + includeInlayParameterNameHintsWhenArgumentMatchesName = true, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + importModuleSpecifierPreference = 'non-relative', + }, + }, + }, -- lua_ls = { @@ -647,6 +664,7 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'prettierd', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -703,7 +721,12 @@ require('lazy').setup({ -- python = { "isort", "black" }, -- -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + javascriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + typescript = { 'prettierd', 'prettier', stop_after_first = true }, + typescriptreact = { 'prettierd', 'prettier', stop_after_first = true }, + + rust = { 'rustfmt' }, }, }, }, @@ -728,12 +751,12 @@ require('lazy').setup({ -- `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, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -888,7 +911,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'regex' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -920,8 +943,8 @@ require('lazy').setup({ -- 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.autopairs', + require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -929,7 +952,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/lsp-signature.lua b/lua/custom/plugins/lsp-signature.lua new file mode 100644 index 00000000..d8db3100 --- /dev/null +++ b/lua/custom/plugins/lsp-signature.lua @@ -0,0 +1,10 @@ +-- https://github.com/ray-x/lsp_signature.nvim +return { + 'ray-x/lsp_signature.nvim', + event = 'VeryLazy', + opts = {}, + config = function(_, opts) + require('lsp_signature').setup(opts) + vim.keymap.set('i', '', vim.lsp.buf.signature_help, { silent = true, noremap = true, desc = 'toggle function signature' }) + end, +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua new file mode 100644 index 00000000..003d7366 --- /dev/null +++ b/lua/custom/plugins/noice.lua @@ -0,0 +1,39 @@ +return { + 'folke/noice.nvim', + event = 'VeryLazy', + opts = { + -- add any options here + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + 'MunifTanjim/nui.nvim', + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + 'rcarriga/nvim-notify', + }, + config = function() + require('noice').setup { + lsp = { + -- need to disable this because of `lsp-signature` + signature = { + enabled = false, + }, + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + } + end, +} diff --git a/lua/custom/plugins/tag-autoclose.lua b/lua/custom/plugins/tag-autoclose.lua new file mode 100644 index 00000000..2916038e --- /dev/null +++ b/lua/custom/plugins/tag-autoclose.lua @@ -0,0 +1,6 @@ +-- https://github.com/windwp/nvim-ts-autotag +return { + 'windwp/nvim-ts-autotag', + opts = {}, + event = 'VeryLazy', +} diff --git a/lua/custom/plugins/tmux.lua b/lua/custom/plugins/tmux.lua new file mode 100644 index 00000000..a9349b4b --- /dev/null +++ b/lua/custom/plugins/tmux.lua @@ -0,0 +1,18 @@ +return { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + }, + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, + }, +} +-- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/ts-comments.lua b/lua/custom/plugins/ts-comments.lua new file mode 100644 index 00000000..3c8bea17 --- /dev/null +++ b/lua/custom/plugins/ts-comments.lua @@ -0,0 +1,6 @@ +-- https://github.com/folke/ts-comments.nvim +return { + 'folke/ts-comments.nvim', + opts = {}, + event = 'VeryLazy', +}