diff --git a/init.lua b/init.lua index 1cfa228b..98b7902d 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,4 @@ --[[ - ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== @@ -35,7 +34,6 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now :) --]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) @@ -75,11 +73,12 @@ require('lazy').setup({ -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. - { -- LSP Configuration & Plugins + { + -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', -- Useful status updates for LSP @@ -91,14 +90,16 @@ require('lazy').setup({ }, }, - { -- Autocompletion + { + -- Autocompletion 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { -- Adds git releated signs to the gutter, as well as utilities for managing changes + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git releated signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- See `:help gitsigns.txt` @@ -111,40 +112,63 @@ require('lazy').setup({ }, }, }, - - { -- Theme inspired by Atom - 'navarasu/onedark.nvim', + -- { + -- 'rebelot/kanagawa.nvim', + -- priority = 1000, + -- config = function() + -- vim.cmd.colorscheme 'kanagawa' + -- end, + -- }, + -- { + -- 'ellisonleao/gruvbox.nvim', + -- priority = 1000, + -- config = function() + -- vim.cmd.colorscheme 'gruvbox' + -- end, + -- }, + -- { + -- -- Theme inspired by Atom + -- 'navarasu/onedark.nvim', + -- priority = 1000, + -- config = function() + -- vim.cmd.colorscheme 'onedark' + -- end, + -- }, + { + 'rose-pine/neovim', priority = 1000, config = function() - vim.cmd.colorscheme 'onedark' + vim.cmd.colorscheme 'rose-pine-main' end, }, - { -- Set lualine as statusline + { + -- Set lualine as statusline 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` opts = { options = { icons_enabled = false, - theme = 'onedark', + theme = 'rose-pine', component_separators = '|', section_separators = '', }, }, }, - { -- Add indentation guides even on blank lines + { + -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` opts = { - char = '┊', + char = '│', show_trailing_blankline_indent = false, }, }, -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Fuzzy Finder (files, lsp, etc) { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, @@ -162,18 +186,21 @@ require('lazy').setup({ end, }, - { -- Highlight, edit, and navigate code + { + -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', }, - build = ":TSUpdate", + config = function() + pcall(require('nvim-treesitter.install').update { with_sync = true }) + end, }, -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.autoformat', -- require 'kickstart.plugins.debug', -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -193,9 +220,38 @@ require('lazy').setup({ -- Set highlight on search vim.o.hlsearch = false +vim.opt.incsearch = true; -- Make line numbers default vim.wo.number = true +-- Set relative numbers +vim.wo.relativenumber = true + +-- Move highlited line with alt +vim.keymap.set("v", "", ":m '>+1gv=gv") +vim.keymap.set("v", "", ":m '<-2gv=gv") +vim.keymap.set("n", "", ":m .+1==") +vim.keymap.set("n", "", ":m .-2==") + +-- Greatest remap ever +vim.keymap.set("x", "", "\"_dP") + +-- /hen searching keep cursor in the middle +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- About quick fixes +-- vim.keymap.set("n", "", "cnextzz") +-- vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +-- set tab configuration +local set = vim.opt -- set options +set.tabstop = 4 +set.softtabstop = 4 +set.shiftwidth = 4 + +set.wrap = false; +set.scrolloff = 8 -- Enable mouse mode vim.o.mouse = 'a' @@ -230,6 +286,8 @@ vim.o.termguicolors = true -- [[ Basic Keymaps ]] +vim.keymap.set('n', '', ':w', { silent = true }) +vim.keymap.set('n', '', ':Neotree toggle', { desc = 'Toggle Tree', silent = true }) -- Keymaps for better default experience -- See `:help vim.keymap.set()` vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) @@ -255,8 +313,8 @@ require('telescope').setup { defaults = { mappings = { i = { - [''] = false, - [''] = false, + [''] = false, + [''] = false, }, }, }, @@ -286,10 +344,10 @@ vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { de -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, + auto_install = true, highlight = { enable = true }, indent = { enable = true, disable = { 'python' } }, @@ -308,41 +366,41 @@ require('nvim-treesitter.configs').setup { lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim keymaps = { -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', }, }, move = { enable = true, set_jumps = true, -- whether to set jumps in the jumplist goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', + [']m'] = '@function.outer', + [']]'] = '@class.outer', }, goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', + [']M'] = '@function.outer', + [']['] = '@class.outer', }, goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', + ['[m'] = '@function.outer', + ['[['] = '@class.outer', }, goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', }, }, swap = { enable = true, swap_next = { - ['a'] = '@parameter.inner', + ['a'] = '@parameter.inner', }, swap_previous = { - ['A'] = '@parameter.inner', + ['A'] = '@parameter.inner', }, }, }, @@ -372,7 +430,8 @@ local on_attach = function(_, bufnr) end nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap('ca', ':CodeActionMenu', '[C]ode [A]ction') + -- nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') @@ -410,7 +469,7 @@ local servers = { -- pyright = {}, -- rust_analyzer = {}, -- tsserver = {}, - + -- eslint = {}, lua_ls = { Lua = { workspace = { checkThirdParty = false }, @@ -426,6 +485,9 @@ require('neodev').setup() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) +-- Setup mason so it can manage external tooling +require('mason').setup() + -- Ensure the servers above are installed local mason_lspconfig = require 'mason-lspconfig' @@ -456,14 +518,14 @@ cmp.setup { end, }, mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, - [''] = cmp.mapping(function(fallback) + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then @@ -472,7 +534,7 @@ cmp.setup { fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then diff --git a/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1 @@ + diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..d2ffe562 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,9 @@ +-- File: lua/custom/plugins/autopairs.lua + +return { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, +} + diff --git a/lua/custom/plugins/code_actions.lua b/lua/custom/plugins/code_actions.lua new file mode 100644 index 00000000..bff8b9db --- /dev/null +++ b/lua/custom/plugins/code_actions.lua @@ -0,0 +1,4 @@ +return { + 'weilbith/nvim-code-action-menu', + +} diff --git a/lua/custom/plugins/filetree.lua b/lua/custom/plugins/filetree.lua new file mode 100644 index 00000000..237f7505 --- /dev/null +++ b/lua/custom/plugins/filetree.lua @@ -0,0 +1,15 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function () + -- Unless you are still migrating, remove the deprecated commands from v1.x + vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + + require('neo-tree').setup {} + end, +} diff --git a/lua/custom/plugins/guess_indent.lua b/lua/custom/plugins/guess_indent.lua new file mode 100644 index 00000000..02112867 --- /dev/null +++ b/lua/custom/plugins/guess_indent.lua @@ -0,0 +1,5 @@ +-- using packer.nvim +return { + 'nmac427/guess-indent.nvim', + config = function() require('guess-indent').setup {} end, +}