diff --git a/init.lua b/init.lua index b98ffc61..04c183f1 100644 --- a/init.lua +++ b/init.lua @@ -84,14 +84,17 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] +-- Custom config. +require 'custom.keybindings' + -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' +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` @@ -110,6 +113,9 @@ vim.o.mouse = 'a' -- Don't show the mode, since it's already in the status line vim.o.showmode = false +-- Disable swapfiles +vim.opt.swapfile = false -- Disable .swp files + -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. @@ -200,10 +206,10 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the lower win vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) -- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes --- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) --- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) --- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) --- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +vim.keymap.set('n', '', 'H', { desc = 'Move window to the left' }) +vim.keymap.set('n', '', 'L', { desc = 'Move window to the right' }) +vim.keymap.set('n', '', 'J', { desc = 'Move window to the lower' }) +vim.keymap.set('n', '', 'K', { desc = 'Move window to the upper' }) -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -672,9 +678,9 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, + 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: @@ -683,7 +689,46 @@ require('lazy').setup({ -- But for many setups, the LSP (`ts_ls`) will work just fine -- ts_ls = {}, -- - + -- Vue 3 + -- + vuels = { + filetypes = { 'vue', 'javascript', 'typescript' }, + init_options = { + config = { + vetur = { -- For Vue 2 compatibility (optional) + validation = { template = true, script = true, style = true }, + format = { enable = false }, -- Disable if using Prettier + }, + }, + }, + }, + -- TypeScript + ts_ls = { + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = vim.fn.stdpath 'data' .. '/mason/packages/vue-language-server/node_modules/@vue/language-server', + languages = { 'vue' }, + }, + }, + }, + settings = { + typescript = { + inlayHints = { + includeInlayParameterNameHints = 'all', + includeInlayParameterNameHintsWhenArgumentMatchesName = true, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayVariableTypeHintsWhenTypeMatchesName = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, + }, lua_ls = { -- cmd = { ... }, -- filetypes = { ... }, @@ -698,6 +743,13 @@ require('lazy').setup({ }, }, }, + + -- python lsp + pyright = {}, + -- CSS/SCSS LSP + cssls = { + filetypes = { 'css', 'scss', 'sass' }, + }, } -- Ensure the servers and tools above are installed @@ -717,10 +769,16 @@ require('lazy').setup({ vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code }) + vim.filetype.add { + extension = { + vue = 'vue', + }, + } require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { - ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + ensure_installed = { 'vuels', 'lua_ls' }, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + automatic_enable = true, automatic_installation = false, handlers = { function(server_name) @@ -772,7 +830,7 @@ 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 }, }, }, }, @@ -809,6 +867,8 @@ require('lazy').setup({ opts = {}, }, 'folke/lazydev.nvim', + -- custom deps + 'Kaiser-Yang/blink-cmp-avante', }, --- @module 'blink.cmp' --- @type blink.cmp.Config @@ -837,6 +897,19 @@ require('lazy').setup({ -- See :h blink-cmp-config-keymap for defining your own keymap preset = 'default', + [''] = { + function(cmp) + if cmp.snippet_active() then + return cmp.accept() + else + return cmp.select_and_accept() + end + vim.api.nvim_command '' + end, + 'snippet_forward', + 'fallback', + }, + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, @@ -851,12 +924,22 @@ require('lazy').setup({ -- 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 }, + ghost_text = { + enabled = true, + }, }, sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, + default = { 'lsp', 'path', 'snippets', 'lazydev', 'avante' }, providers = { lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + avante = { + module = 'blink-cmp-avante', + name = 'Avante', + opts = { + -- options for blink-cmp-avante + }, + }, }, }, @@ -917,7 +1000,19 @@ 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 = { + [')'] = { output = { left = '( ', right = ' )' } }, + ['('] = { output = { left = '(', right = ')' } }, + ['{'] = { output = { left = '{\n', right = '\n}' } }, + ['['] = { output = { left = '[', right = ']' } }, + }, + } + + -- // custom mini plugins + -- + require('mini.starter').setup() + -- require('mini.bufremove').setup() -- Simple and easy statusline. -- You could remove this setup call if you don't like it, @@ -944,7 +1039,24 @@ 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', + 'html', + 'javascript', + 'typescript', + 'tsx', + 'vue', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -955,6 +1067,9 @@ require('lazy').setup({ additional_vim_regex_highlighting = { 'ruby' }, }, indent = { enable = true, disable = { 'ruby' } }, + autotag = { + enabled = true, + }, }, -- 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: @@ -974,17 +1089,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.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.nvim-ts-autotag', -- adds nvim-ts-autotag -- 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/lua/custom/keybindings.lua b/lua/custom/keybindings.lua new file mode 100644 index 00000000..e5be4a4f --- /dev/null +++ b/lua/custom/keybindings.lua @@ -0,0 +1,14 @@ +-- Custom Keybinds. + +vim.keymap.set('i', 'jk', '', { desc = 'escape' }) +vim.keymap.set('i', 'kj', '', { desc = 'escape' }) + +vim.keymap.set('n', ',,', 'ToggleTerm', { desc = 'Open terminal in horizontal split' }) +vim.keymap.set('t', ',,', 'ToggleTerm', { desc = 'Open terminal in horizontal split' }) + +-- vim.keymap.set('n', '', 'bdelete') + +-- Change buffer by number (example Alt+1, Alt+2...) +for i = 1, 9 do + vim.keymap.set('n', '', 'BufferLineGoToBuffer ' .. i .. '') +end diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..26d81232 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,5 +1,122 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'akinsho/bufferline.nvim', + dependencies = 'nvim-tree/nvim-web-devicons', + + event = 'VeryLazy', + keys = { + { '', 'BufferLineCyclePrev', desc = 'Prev Buffer' }, + { '', 'BufferLineCycleNext', desc = 'Next Buffer' }, + { '', 'BufferLineMovePrev', desc = 'Move buffer prev' }, + { '', 'BufferLineMoveNext', desc = 'Move buffer next' }, + }, + opts = { + options = { + diagnostics = 'nvim_lsp', + always_show_bufferline = true, + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local icon = level:match 'error' and ' ' or ' ' + return ' ' .. icon .. count + end, + offsets = { + { + filetype = 'neo-tree', + text = 'Neo-tree', + highlight = 'Directory', + text_align = 'left', + }, + { + filetype = 'snacks_layout_box', + }, + }, + show_buffer_icons = true, + color_icons = true, + }, + }, + }, + { + 'mattn/emmet-vim', + }, + { + 'yetone/avante.nvim', + event = 'VeryLazy', + version = false, -- Never set this value to "*"! Never! + opts = { + provider = 'deepseek', + providers = { + deepseek = { + __inherited_from = 'openai', + api_key_name = 'DEEPSEEK_API_KEY', + endpoint = 'https://api.deepseek.com', + model = 'deepseek-coder', + }, + }, + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = 'make', + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- The below dependencies are optional, + 'echasnovski/mini.pick', -- for file_selector provider mini.pick + 'nvim-telescope/telescope.nvim', -- for file_selector provider telescope + 'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions + -- 'ibhagwan/fzf-lua', -- for file_selector provider fzf + -- 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons + 'echasnovski/mini.icons', -- or echasnovski/mini.icons + -- 'zbirenbaum/copilot.lua', -- for providers='copilot' + -- { + -- -- support for image pasting + -- 'HakonHarnes/img-clip.nvim', + -- event = 'VeryLazy', + -- opts = { + -- -- recommended settings + -- default = { + -- embed_image_as_base64 = false, + -- prompt_for_file_name = false, + -- drag_and_drop = { + -- insert_mode = true, + -- }, + -- -- required for Windows users + -- use_absolute_path = true, + -- }, + -- }, + -- }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, + }, + { 'akinsho/toggleterm.nvim', version = '*', opts = {} }, + { + 'antosha417/nvim-lsp-file-operations', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Uncomment whichever supported plugin(s) you use + -- "nvim-tree/nvim-tree.lua", + 'nvim-neo-tree/neo-tree.nvim', + -- "simonmclean/triptych.nvim" + }, + config = function() + require('lsp-file-operations').setup() + end, + }, + { + 'nvim-treesitter/nvim-treesitter', + dependencies = { + -- Add nvim-ts-autotag + { 'windwp/nvim-ts-autotag' }, + }, + opts = {}, + }, +} diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua deleted file mode 100644 index 386d392e..00000000 --- a/lua/kickstart/plugins/autopairs.lua +++ /dev/null @@ -1,8 +0,0 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - opts = {}, -} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index c7067891..34ce6c5a 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -11,13 +11,44 @@ return { }, lazy = false, keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + { 'e', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { filesystem = { + bind_to_cwd = true, + commands = { + avante_add_files = function(state) + local node = state.tree:get_node() + local filepath = node:get_id() + local relative_path = require('avante.utils').relative_path(filepath) + + local sidebar = require('avante').get() + + local open = sidebar:is_open() + -- ensure avante sidebar is open + if not open then + require('avante.api').ask() + sidebar = require('avante').get() + end + + sidebar.file_selector:add_selected_file(relative_path) + + -- remove neo tree buffer + if not open then + sidebar.file_selector:remove_selected_file 'neo-tree filesystem [1]' + end + end, + }, window = { mappings = { - ['\\'] = 'close_window', + ['e'] = 'close_window', + [''] = { + 'open', + config = { + open_command = 'tabnew', + }, + }, + ['oa'] = 'avante_add_files', }, }, }, diff --git a/lua/kickstart/plugins/nvim-ts-autotag.lua b/lua/kickstart/plugins/nvim-ts-autotag.lua new file mode 100644 index 00000000..3272de25 --- /dev/null +++ b/lua/kickstart/plugins/nvim-ts-autotag.lua @@ -0,0 +1,5 @@ +return { + 'windwp/nvim-ts-autotag', + event = 'InsertEnter', + opts = {}, +}