diff --git a/init.lua b/init.lua index b98ffc6198a..b23e40497e3 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.o` @@ -219,6 +219,8 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +vim.lsp.enable 'tsgo' + -- [[ 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' @@ -427,15 +429,15 @@ require('lazy').setup({ -- 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', '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' }) + -- 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() @@ -655,6 +657,14 @@ require('lazy').setup({ }, } + vim.keymap.set('n', '[d', function() + vim.diagnostic.jump { count = -1, float = true } + end, { desc = 'Go to previous diagnostic with float' }) + + vim.keymap.set('n', ']d', function() + vim.diagnostic.jump { count = 1, float = true } + end, { desc = 'Go to next diagnostic with float' }) + -- 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. @@ -682,7 +692,17 @@ require('lazy').setup({ -- -- But for many setups, the LSP (`ts_ls`) will work just fine -- ts_ls = {}, - -- + -- vtsls = { + -- settings = { + -- typescript = { + -- preferences = { + -- includeCompletionsForModuleExports = true, + -- includeCompletionsForImportStatements = true, + -- importModuleSpecifier = 'non-relative', + -- }, + -- }, + -- }, + -- }, lua_ls = { -- cmd = { ... }, @@ -768,6 +788,11 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + astro = { 'biome', 'prettierd' }, + javascript = { 'biome', 'prettierd' }, + typescript = { 'biome', 'prettierd' }, + javascriptreact = { 'biome', 'prettierd' }, + typescriptreact = { 'biome', 'prettierd' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -850,11 +875,24 @@ require('lazy').setup({ 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 }, + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + accept = { + auto_brackets = { + kind_resolution = { + blocked_filetypes = { 'typescriptreact', 'javascriptreact', 'vue', 'astro' }, + }, + semantic_token_resolution = { + blocked_filetypes = { 'java', 'astro' }, + }, + }, + }, }, sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, + default = { 'lsp', 'path', 'snippets' }, + per_filetype = { + lua = { inherit_defaults = true, 'lazydev' }, + }, providers = { lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, }, @@ -872,7 +910,7 @@ require('lazy').setup({ fuzzy = { implementation = 'lua' }, -- Shows a signature help window while you type arguments for a function - signature = { enabled = true }, + signature = { enabled = true, window = { show_documentation = true } }, }, }, @@ -917,7 +955,20 @@ require('lazy').setup({ -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() + require('mini.surround').setup { + custom_surroundings = { + T = { + input = { '<(%w+)[^<>]->.-', '^<()%w+().*$' }, + output = function() + local tag_name = MiniSurround.user_input 'Tag name' + if tag_name == nil then + return nil + end + return { left = tag_name, right = tag_name } + end, + }, + }, + } -- Simple and easy statusline. -- You could remove this setup call if you don't like it, @@ -934,6 +985,10 @@ require('lazy').setup({ return '%2l:%-2v' end + require('mini.pairs').setup() + + require('mini.move').setup() + -- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim end, @@ -942,6 +997,8 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', main = 'nvim-treesitter.configs', -- Sets main module to use for opts + dependencies = { 'OXY2DEV/markview.nvim' }, + lazy = false, -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, @@ -974,17 +1031,17 @@ 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.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lsp/tsgo.lua b/lsp/tsgo.lua new file mode 100644 index 00000000000..301866cac63 --- /dev/null +++ b/lsp/tsgo.lua @@ -0,0 +1,5 @@ +return { + cmd = { 'tsgo', '--lsp', '--stdio' }, + filteypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' }, + root_markers = { 'tsconfig.json', 'package.json', '.git' }, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..c2020fb7506 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,272 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) + +vim.g.copilot_enabled = false -- Disable Copilot by default +vim.keymap.set('n', 'cpd', ':Copilot disable', { silent = true, noremap = true }) -- Disable Copilot +vim.keymap.set('n', 'cpe', ':Copilot enable', { silent = true, noremap = true }) -- Enable Copilot + +vim.g.copilot_enabled = false + +return { + { + 'sindrets/diffview.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require('diffview').setup { + diff_binaries = false, -- Show diffs for binaries + enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl' + git_cmd = { 'git' }, -- The git executable followed by default args. + use_icons = true, -- Requires nvim-web-devicons + show_help_hints = true, -- Show hints for how to open the help panel + watch_index = true, -- Update views and index on git index changes. + icons = { -- Only applies when use_icons is true. + folder_closed = '', + folder_open = '', + }, + signs = { + fold_closed = '', + fold_open = '', + done = '✓', + }, + view = { + -- Configure the layout and behavior of different types of views. + -- Available layouts: + -- 'diff1_plain' + -- |'diff2_horizontal' + -- |'diff2_vertical' + -- |'diff3_horizontal' + -- |'diff3_vertical' + -- |'diff3_mixed' + -- |'diff4_mixed' + -- For more info, see ':h diffview-config-view.x.layout'. + default = { + -- Config for changed files, and staged files in diff views. + layout = 'diff2_horizontal', + winbar_info = false, -- See ':h diffview-config-view.x.winbar_info' + }, + merge_tool = { + -- Config for conflicted files in diff views during a merge or rebase. + layout = 'diff3_horizontal', + disable_diagnostics = true, -- Temporarily disable diagnostics for conflict buffers while in the view. + winbar_info = true, -- See ':h diffview-config-view.x.winbar_info' + }, + }, + } + + -- Diffview keymaps + vim.keymap.set('n', 'gd', ':DiffviewOpen', { desc = 'Open Diffview' }) + vim.keymap.set('n', 'gc', ':DiffviewClose', { desc = 'Close Diffview' }) + vim.keymap.set('n', 'gm', ':DiffviewOpen HEAD~1', { desc = 'Compare with previous commit' }) + vim.keymap.set('n', 'gh', ':DiffviewFileHistory', { desc = 'File history' }) + vim.keymap.set('n', 'gH', ':DiffviewFileHistory %', { desc = 'Current file history' }) + + -- For merge conflicts specifically + vim.keymap.set('n', 'gco', ':DiffviewOpen', { desc = 'Open merge conflict view' }) + end, + }, + { + 'olrtg/nvim-emmet', + config = function() + vim.keymap.set({ 'n', 'v' }, 'xe', require('nvim-emmet').wrap_with_abbreviation) + end, + }, + -- { + -- 'nvimdev/indentmini.nvim', + -- config = function() + -- require('indentmini').setup() + -- end, + -- }, + { + 'ibhagwan/fzf-lua', + dependencies = { 'echasnovski/mini.icons' }, + opts = {}, + config = function() + require('fzf-lua').setup {} + + local builtin = require 'fzf-lua' + + vim.keymap.set('n', 'sf', builtin.files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 'sw', builtin.grep_cword, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', '/', builtin.lgrep_curbuf, { desc = '[/] Fuzzily search in current buffer' }) + vim.keymap.set('n', 'sd', builtin.diagnostics_document, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sG', function() + builtin.live_grep { + file_ignore_patterns = { + '%.spec%.', + '%.test%.', + }, + } + end, { desc = '[S]earch by [G]rep without Tests' }) + end, + }, + 'JoosepAlviste/nvim-ts-context-commentstring', + { + 'iamcco/markdown-preview.nvim', + cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, + ft = { 'markdown' }, + build = ':call mkdp#util#install()', + }, + { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + }, + -- lazy.nvim + { + 'folke/noice.nvim', + event = 'VeryLazy', + opts = { + -- add any options here + }, + config = function() + require('noice').setup { + lsp = { + 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 = false, -- 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 = true, -- add a border to hover docs and signature help + }, + } + end, + 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', + }, + }, + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup { + sections = { + lualine_x = { + { + require('noice').api.statusline.mode.get, + cond = require('noice').api.statusline.mode.has, + color = { fg = '#ff9e64' }, + }, + }, + }, + } + end, + }, + { + 'nvimdev/lspsaga.nvim', + config = function() + require('lspsaga').setup {} + end, + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-tree/nvim-web-devicons', + }, + }, + { + 'folke/trouble.nvim', + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = 'Trouble', + keys = { + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'Diagnostics (Trouble)', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Buffer Diagnostics (Trouble)', + }, + { + 'cs', + 'Trouble symbols toggle focus=false', + desc = 'Symbols (Trouble)', + }, + { + 'cl', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'LSP Definitions / references / ... (Trouble)', + }, + { + 'xL', + 'Trouble loclist toggle', + desc = 'Location List (Trouble)', + }, + { + 'xQ', + 'Trouble qflist toggle', + desc = 'Quickfix List (Trouble)', + }, + }, + }, + { + 'windwp/nvim-ts-autotag', + opts = {}, + }, + + { + 'ray-x/lsp_signature.nvim', + event = 'VeryLazy', + enabled = false, + opts = { + toggle_key = '', -- toggle signature help on and off + }, + config = function(_, opts) + require('lsp_signature').setup(opts) + end, + }, + { + 'olimorris/codecompanion.nvim', + opts = {}, + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + }, + config = function() + require('codecompanion').setup { + strategies = { + chat = { + adapter = 'copilot', + }, + inline = { + adapter = 'copilot', + }, + agent = { + adapter = 'copilot', + }, + }, + } + end, + }, + { + 'github/copilot.vim', + lazy = false, + config = function() end, + }, +}