diff --git a/backup/onedark.lua.theme b/backup/onedark.lua.theme new file mode 100644 index 00000000..d7b44b21 --- /dev/null +++ b/backup/onedark.lua.theme @@ -0,0 +1,12 @@ +return { + -- Theme inspired by Atom + 'navarasu/onedark.nvim', + priority = 1000, + config = function() + require('onedark').setup { + style = 'warm', + } + require('onedark').load() + vim.cmd.colorscheme 'onedark' + end, +} diff --git a/init.lua b/init.lua index 03cfc5bc..4be9021f 100644 --- a/init.lua +++ b/init.lua @@ -25,38 +25,6 @@ require('lazy').setup({ -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', - { - -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', - - -- Useful status updates for LSP - { 'j-hui/fidget.nvim', opts = {} }, - - -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', - }, - }, - - { - -- Autocompletion - 'hrsh7th/nvim-cmp', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', - - -- Adds LSP completion capabilities - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', - - -- Adds a number of user-friendly snippets - 'rafamadriz/friendly-snippets', - }, - }, -- Useful plugin to show you pending keybinds. { 'folke/which-key.nvim', opts = {} }, @@ -135,33 +103,6 @@ require('lazy').setup({ }, }, - { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - config = function() - require("onedark").setup { - style = "warm" - } - require("onedark").load() - vim.cmd.colorscheme 'onedark' - end, - }, - - { - -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = false, - theme = 'onedark', - component_separators = '|', - section_separators = '', - }, - }, - }, - { -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', @@ -173,34 +114,7 @@ require('lazy').setup({ -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, - { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - }, - }, - - { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ':TSUpdate', - }, - - require 'kickstart.plugins.autoformat', - require 'kickstart.plugins.debug', - - { import = 'custom.plugins' }, + { import = 'plugins' }, }, {}) -- [[ Setting options ]] @@ -266,159 +180,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- Telescope live_grep in git root --- Function to find the git root directory based on the current buffer's path -local function find_git_root() - -- Use the current buffer's path as the starting point for the git search - local current_file = vim.api.nvim_buf_get_name(0) - local current_dir - local cwd = vim.fn.getcwd() - -- If the buffer is not associated with a file, return nil - if current_file == '' then - current_dir = cwd - else - -- Extract the directory from the current file's path - current_dir = vim.fn.fnamemodify(current_file, ':h') - end - - -- Find the Git root directory from the current file's path - local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] - if vim.v.shell_error ~= 0 then - print 'Not a git repository. Searching on current working directory' - return cwd - end - return git_root -end - --- Custom live_grep function to search in git root -local function live_grep_git_root() - local git_root = find_git_root() - if git_root then - require('telescope.builtin').live_grep { - search_dirs = { git_root }, - } - end -end - -vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -local function telescope_live_grep_open_files() - require('telescope.builtin').live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } -end -vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) -vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` -vim.defer_fn(function() - 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', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = true, - -- Install languages synchronously (only applied to `ensure_installed`) - sync_install = false, - -- List of parsers to ignore installing - ignore_install = {}, - -- You can specify additional Treesitter modules here: -- For example: -- playground = {--enable = true,-- }, - modules = {}, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - 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', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, - } -end, 0) - -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..9ce8a51f --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,37 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "fidget.nvim": { "branch": "main", "commit": "3a93300c076109d86c7ce35ec67a8034ae6ba9db" }, + "friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" }, + "gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" }, + "image.nvim": { "branch": "master", "commit": "245422e5c4774f0640d41c0eadec77396f2be4a9" }, + "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" }, + "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, + "neodev.nvim": { "branch": "main", "commit": "dde00106b9094f101980b364fae02fd85d357306" }, + "none-ls.nvim": { "branch": "main", "commit": "7e146f3a188853843bb4ca1bff24c912bb9b7177" }, + "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-dap": { "branch": "master", "commit": "aad46274f09ba29933e4cef2257cdda5ec19cf7a" }, + "nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" }, + "nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" }, + "nvim-lspconfig": { "branch": "master", "commit": "e47ccfae775f0d572ef0f3a7d245f043b259dafc" }, + "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" }, + "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, + "onedark.nvim": { "branch": "master", "commit": "dc3bad0121298f89b50aaff8599d1946e07eb4c2" }, + "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/lua/custom/plugins/*/plugins/autocomplete.lua b/lua/custom/plugins/*/plugins/autocomplete.lua new file mode 100644 index 00000000..2d3b9832 --- /dev/null +++ b/lua/custom/plugins/*/plugins/autocomplete.lua @@ -0,0 +1,16 @@ +return { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, +} diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/custom/plugins/*/plugins/autoformat.lua similarity index 100% rename from lua/kickstart/plugins/autoformat.lua rename to lua/custom/plugins/*/plugins/autoformat.lua diff --git a/lua/kickstart/plugins/debug.lua b/lua/custom/plugins/*/plugins/debug.lua similarity index 100% rename from lua/kickstart/plugins/debug.lua rename to lua/custom/plugins/*/plugins/debug.lua diff --git a/lua/custom/plugins/*/plugins/gruvbox.lua b/lua/custom/plugins/*/plugins/gruvbox.lua new file mode 100644 index 00000000..f1383067 --- /dev/null +++ b/lua/custom/plugins/*/plugins/gruvbox.lua @@ -0,0 +1,10 @@ +return { + 'ellisonleao/gruvbox.nvim', + priority = 1000, + -- config = true, + opts = ..., + config = function() + vim.o.background = 'dark' + vim.cmd [[colorscheme gruvbox]] + end, +} diff --git a/lua/custom/plugins/*/plugins/lsp-config.lua b/lua/custom/plugins/*/plugins/lsp-config.lua new file mode 100644 index 00000000..97568066 --- /dev/null +++ b/lua/custom/plugins/*/plugins/lsp-config.lua @@ -0,0 +1,15 @@ +return { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + { 'j-hui/fidget.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, +} diff --git a/lua/custom/plugins/*/plugins/lualine.lua b/lua/custom/plugins/*/plugins/lualine.lua new file mode 100644 index 00000000..82bce4ed --- /dev/null +++ b/lua/custom/plugins/*/plugins/lualine.lua @@ -0,0 +1,13 @@ +return { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, + }, +} diff --git a/lua/custom/plugins/*/plugins/neo-tree.lua b/lua/custom/plugins/*/plugins/neo-tree.lua new file mode 100644 index 00000000..4dacd80b --- /dev/null +++ b/lua/custom/plugins/*/plugins/neo-tree.lua @@ -0,0 +1,16 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + '3rd/image.nvim', + }, + keys = { + { '', 'Neotree toggle', desc = '[F]iles with Neotree' }, + -- config = function() + -- require("neo-tree").setup() + -- end, + }, +} diff --git a/lua/custom/plugins/*/plugins/none-ls.lua b/lua/custom/plugins/*/plugins/none-ls.lua new file mode 100644 index 00000000..2b40c809 --- /dev/null +++ b/lua/custom/plugins/*/plugins/none-ls.lua @@ -0,0 +1,14 @@ +return { + 'nvimtools/none-ls.nvim', + config = function() + local null_ls = require 'null-ls' + null_ls.setup { + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.diagnostics.eslint, + null_ls.builtins.completion.spell, + }, + } + vim.keymap.set('n', 'cf', vim.lsp.buf.format, { desc = '[C]ode [f]ormatting' }) + end, +} diff --git a/lua/custom/plugins/*/plugins/telescope.lua b/lua/custom/plugins/*/plugins/telescope.lua new file mode 100644 index 00000000..417cb527 --- /dev/null +++ b/lua/custom/plugins/*/plugins/telescope.lua @@ -0,0 +1,96 @@ +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + config = function() + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + local telescope = require 'telescope' + telescope.setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + } + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + + -- Telescope live_grep in git root + -- Function to find the git root directory based on the current buffer's path + local function find_git_root() + -- Use the current buffer's path as the starting point for the git search + local current_file = vim.api.nvim_buf_get_name(0) + local current_dir + local cwd = vim.fn.getcwd() + -- If the buffer is not associated with a file, return nil + if current_file == '' then + current_dir = cwd + else + -- Extract the directory from the current file's path + current_dir = vim.fn.fnamemodify(current_file, ':h') + end + + -- Find the Git root directory from the current file's path + local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel') + [1] + if vim.v.shell_error ~= 0 then + print 'Not a git repository. Searching on current working directory' + return cwd + end + return git_root + end + + -- Custom live_grep function to search in git root + local function live_grep_git_root() + local git_root = find_git_root() + if git_root then + require('telescope.builtin').live_grep { + search_dirs = { git_root }, + } + end + end + + vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) + + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + local function telescope_live_grep_open_files() + require('telescope.builtin').live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end + vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) + vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + end, +} diff --git a/lua/custom/plugins/*/plugins/treesitter.lua b/lua/custom/plugins/*/plugins/treesitter.lua new file mode 100644 index 00000000..b84e972e --- /dev/null +++ b/lua/custom/plugins/*/plugins/treesitter.lua @@ -0,0 +1,84 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', -- This command is run after installation to update Treesitter parsers + config = function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for Treesitter + ensure_installed = { 'lua', 'python', 'rust', 'markdown', 'vimdoc', 'vim', 'bash' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = true, + + -- Install languages synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- List of parsers to ignore installing + ignore_install = { '' }, + + highlight = { + enable = true, -- false will disable the whole extension + }, + + indent = { + enable = true, -- Indentation based on treesitter for supported languages + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + + textobjects = { + select = { + enable = true, + 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', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } + end, + }, +} diff --git a/lua/custom/plugins/*/plugins/vim-settings.lua b/lua/custom/plugins/*/plugins/vim-settings.lua new file mode 100644 index 00000000..19cdb84e --- /dev/null +++ b/lua/custom/plugins/*/plugins/vim-settings.lua @@ -0,0 +1,6 @@ +return { + vim.cmd 'set expandtab', + vim.cmd 'set tabstop=2', + vim.cmd 'set softtabstop=2', + vim.cmd 'set shiftwidth=2', +} diff --git a/lua/custom/plugins/neo-tree.lua b/lua/custom/plugins/neo-tree.lua deleted file mode 100644 index 422391b7..00000000 --- a/lua/custom/plugins/neo-tree.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - "3rd/image.nvim", - }, - keys = { - { "ft", "Neotree reveal left", desc = "NeoTree" }, - -- config = function() - -- require("neo-tree").setup() - -- end, - } -} diff --git a/lua/custom/plugins/vim-settings.lua b/lua/custom/plugins/vim-settings.lua deleted file mode 100644 index 2f54fccd..00000000 --- a/lua/custom/plugins/vim-settings.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - vim.cmd("set expandtab"), - vim.cmd("set tabstop=2"), - vim.cmd("set softtabstop=2"), - vim.cmd("set shiftwidth=2"), -} diff --git a/lua/plugins/autocomplete.lua b/lua/plugins/autocomplete.lua new file mode 100644 index 00000000..2d3b9832 --- /dev/null +++ b/lua/plugins/autocomplete.lua @@ -0,0 +1,16 @@ +return { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, +} diff --git a/lua/plugins/autoformat.lua b/lua/plugins/autoformat.lua new file mode 100644 index 00000000..bc56b15b --- /dev/null +++ b/lua/plugins/autoformat.lua @@ -0,0 +1,74 @@ +-- autoformat.lua +-- +-- Use your language server to automatically format your code on save. +-- Adds additional commands as well to manage the behavior + +return { + 'neovim/nvim-lspconfig', + config = function() + -- Switch for controlling whether you want autoformatting. + -- Use :KickstartFormatToggle to toggle autoformatting on or off + local format_is_enabled = true + vim.api.nvim_create_user_command('KickstartFormatToggle', function() + format_is_enabled = not format_is_enabled + print('Setting autoformatting to: ' .. tostring(format_is_enabled)) + end, {}) + + -- Create an augroup that is used for managing our formatting autocmds. + -- We need one augroup per client to make sure that multiple clients + -- can attach to the same buffer without interfering with each other. + local _augroups = {} + local get_augroup = function(client) + if not _augroups[client.id] then + local group_name = 'kickstart-lsp-format-' .. client.name + local id = vim.api.nvim_create_augroup(group_name, { clear = true }) + _augroups[client.id] = id + end + + return _augroups[client.id] + end + + -- Whenever an LSP attaches to a buffer, we will run this function. + -- + -- See `:help LspAttach` for more information about this autocmd event. + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), + -- This is where we attach the autoformatting for reasonable clients + callback = function(args) + local client_id = args.data.client_id + local client = vim.lsp.get_client_by_id(client_id) + local bufnr = args.buf + + -- Only attach to clients that support document formatting + if not client.server_capabilities.documentFormattingProvider then + return + end + + -- Tsserver usually works poorly. Sorry you work with bad languages + -- You can remove this line if you know what you're doing :) + if client.name == 'tsserver' then + return + end + + -- Create an autocmd that will run *before* we save the buffer. + -- Run the formatting command for the LSP that has just attached. + vim.api.nvim_create_autocmd('BufWritePre', { + group = get_augroup(client), + buffer = bufnr, + callback = function() + if not format_is_enabled then + return + end + + vim.lsp.buf.format { + async = false, + filter = function(c) + return c.id == client.id + end, + } + end, + }) + end, + }) + end, +} diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua new file mode 100644 index 00000000..7fc783fa --- /dev/null +++ b/lua/plugins/debug.lua @@ -0,0 +1,87 @@ +-- debug.lua +-- +-- Shows how to use the DAP plugin to debug your code. +-- +-- Primarily focused on configuring the debugger for Go, but can +-- be extended to other languages as well. That's why it's called +-- kickstart.nvim and not kitchen-sink.nvim ;) + +return { + -- NOTE: Yes, you can install new plugins here! + 'mfussenegger/nvim-dap', + -- NOTE: And you can specify dependencies as well + dependencies = { + -- Creates a beautiful debugger UI + 'rcarriga/nvim-dap-ui', + + -- Installs the debug adapters for you + 'williamboman/mason.nvim', + 'jay-babu/mason-nvim-dap.nvim', + + -- Add your own debuggers here + 'leoluz/nvim-dap-go', + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_setup = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, + } + + -- 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 { + -- Set icons to characters that are more likely to work in every terminal. + -- Feel free to remove or use ones that you like more! :) + -- Don't feel like these are good choices. + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + } + + -- 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.' }) + + 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() + end, +} diff --git a/lua/plugins/gruvbox.lua b/lua/plugins/gruvbox.lua new file mode 100644 index 00000000..f1383067 --- /dev/null +++ b/lua/plugins/gruvbox.lua @@ -0,0 +1,10 @@ +return { + 'ellisonleao/gruvbox.nvim', + priority = 1000, + -- config = true, + opts = ..., + config = function() + vim.o.background = 'dark' + vim.cmd [[colorscheme gruvbox]] + end, +} diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua new file mode 100644 index 00000000..97568066 --- /dev/null +++ b/lua/plugins/lsp-config.lua @@ -0,0 +1,15 @@ +return { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + { 'j-hui/fidget.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 00000000..82bce4ed --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,13 @@ +return { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 00000000..4dacd80b --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,16 @@ +return { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + '3rd/image.nvim', + }, + keys = { + { '', 'Neotree toggle', desc = '[F]iles with Neotree' }, + -- config = function() + -- require("neo-tree").setup() + -- end, + }, +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua new file mode 100644 index 00000000..2b40c809 --- /dev/null +++ b/lua/plugins/none-ls.lua @@ -0,0 +1,14 @@ +return { + 'nvimtools/none-ls.nvim', + config = function() + local null_ls = require 'null-ls' + null_ls.setup { + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.diagnostics.eslint, + null_ls.builtins.completion.spell, + }, + } + vim.keymap.set('n', 'cf', vim.lsp.buf.format, { desc = '[C]ode [f]ormatting' }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 00000000..417cb527 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,96 @@ +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + config = function() + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + local telescope = require 'telescope' + telescope.setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + } + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + + -- Telescope live_grep in git root + -- Function to find the git root directory based on the current buffer's path + local function find_git_root() + -- Use the current buffer's path as the starting point for the git search + local current_file = vim.api.nvim_buf_get_name(0) + local current_dir + local cwd = vim.fn.getcwd() + -- If the buffer is not associated with a file, return nil + if current_file == '' then + current_dir = cwd + else + -- Extract the directory from the current file's path + current_dir = vim.fn.fnamemodify(current_file, ':h') + end + + -- Find the Git root directory from the current file's path + local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel') + [1] + if vim.v.shell_error ~= 0 then + print 'Not a git repository. Searching on current working directory' + return cwd + end + return git_root + end + + -- Custom live_grep function to search in git root + local function live_grep_git_root() + local git_root = find_git_root() + if git_root then + require('telescope.builtin').live_grep { + search_dirs = { git_root }, + } + end + end + + vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) + + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + local function telescope_live_grep_open_files() + require('telescope.builtin').live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end + vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) + vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 00000000..b84e972e --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,84 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', -- This command is run after installation to update Treesitter parsers + config = function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for Treesitter + ensure_installed = { 'lua', 'python', 'rust', 'markdown', 'vimdoc', 'vim', 'bash' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = true, + + -- Install languages synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- List of parsers to ignore installing + ignore_install = { '' }, + + highlight = { + enable = true, -- false will disable the whole extension + }, + + indent = { + enable = true, -- Indentation based on treesitter for supported languages + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + + textobjects = { + select = { + enable = true, + 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', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } + end, + }, +} diff --git a/lua/plugins/vim-settings.lua b/lua/plugins/vim-settings.lua new file mode 100644 index 00000000..19cdb84e --- /dev/null +++ b/lua/plugins/vim-settings.lua @@ -0,0 +1,6 @@ +return { + vim.cmd 'set expandtab', + vim.cmd 'set tabstop=2', + vim.cmd 'set softtabstop=2', + vim.cmd 'set shiftwidth=2', +}