From 0cf6219bdf87bc27fb379a3fed616837d739e300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hend=C3=A9n?= Date: Fri, 22 Nov 2024 09:58:47 -0400 Subject: [PATCH] huge reordering of config add codeium plugin change keymaps for completion picker to up/down/tab remove comments compact config --- init.lua | 216 +++++++------------ lua/{custom/plugins => core}/colorscheme.lua | 0 lua/{custom/plugins => core}/keymaps.lua | 24 ++- lua/custom/plugins/init.lua | 5 - lua/{kickstart => }/plugins/autopairs.lua | 0 lua/plugins/codeium.lua | 17 ++ lua/{kickstart => }/plugins/debug.lua | 0 lua/{kickstart => }/plugins/gitsigns.lua | 0 lua/{kickstart => plugins}/health.lua | 0 lua/{kickstart => }/plugins/indent_line.lua | 0 lua/{kickstart => }/plugins/lint.lua | 0 lua/{kickstart => }/plugins/neo-tree.lua | 0 lua/plugins/terraform.lua | 4 + 13 files changed, 116 insertions(+), 150 deletions(-) rename lua/{custom/plugins => core}/colorscheme.lua (100%) rename lua/{custom/plugins => core}/keymaps.lua (66%) delete mode 100644 lua/custom/plugins/init.lua rename lua/{kickstart => }/plugins/autopairs.lua (100%) create mode 100644 lua/plugins/codeium.lua rename lua/{kickstart => }/plugins/debug.lua (100%) rename lua/{kickstart => }/plugins/gitsigns.lua (100%) rename lua/{kickstart => plugins}/health.lua (100%) rename lua/{kickstart => }/plugins/indent_line.lua (100%) rename lua/{kickstart => }/plugins/lint.lua (100%) rename lua/{kickstart => }/plugins/neo-tree.lua (100%) create mode 100644 lua/plugins/terraform.lua diff --git a/init.lua b/init.lua index dc125a01..65493d8d 100644 --- a/init.lua +++ b/init.lua @@ -1,55 +1,14 @@ --[[ -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. + - Lua + - quick guide: https://learnxinyminutes.com/docs/lua/ - :help lua-guide - (or HTML version): https://neovim.io/doc/user/lua-guide.html -Kickstart Guide: + HELP - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. + - keymap "sh" to [s]earch the [h]elp documentation, + - several `:help X` comments throughout the init.lua NOTE: Look for lines like this @@ -57,38 +16,22 @@ Kickstart Guide: Feel free to delete them once you know what you're doing, but they should serve as a guide for when you are first encountering a few different constructs in your Neovim config. -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -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 loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' +vim.g.mapleader = ' ' -- Set as the leader key 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 -- Set to true if you have a Nerd Font installed and selected in the terminal -- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default --- You can also add relative line numbers, to help with jumping. -vim.opt.number = false -vim.opt.relativenumber = false +-- :help vim.opt +-- :help option-list --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' - --- Don't show the mode, since it's already in the status line -vim.opt.showmode = false +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.mouse = 'a' -- Enable mouse mode, can be useful for resizing splits for example! +vim.opt.showmode = false -- Don't show the mode, since it's already in the status line -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. @@ -98,29 +41,15 @@ vim.schedule(function() vim.opt.clipboard = 'unnamedplus' end) --- Enable break indent -vim.opt.breakindent = true - --- Save undo history -vim.opt.undofile = false - --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.opt.ignorecase = true +vim.opt.breakindent = true -- Enable break indent +vim.opt.undofile = false -- Do not save undo history (no undo beyond last save) +vim.opt.ignorecase = true -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term vim.opt.smartcase = true - --- Keep signcolumn on by default -vim.opt.signcolumn = 'yes' - --- Decrease update time -vim.opt.updatetime = 250 - --- Decrease mapped sequence wait time --- Displays which-key popup sooner -vim.opt.timeoutlen = 300 - --- Configure how new splits should be opened -vim.opt.splitright = true -vim.opt.splitbelow = true +vim.opt.signcolumn = 'yes' -- Keep signcolumn on by default +vim.opt.updatetime = 250 -- Decrease update time +vim.opt.timeoutlen = 300 -- Decrease mapped sequence wait time + displays which-key popup sooner +vim.opt.splitright = true -- Configure how new splits should be opened +vim.opt.splitbelow = true -- Configure how new splits should be opened -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` @@ -129,14 +58,23 @@ vim.opt.list = false --vim.opt.listchars = { tab = '» ', trail = '·', eol = '$', nbsp = '␣' } vim.opt.listchars = { tab = '▸·', trail = '▸', eol = '$', nbsp = '␣' } --- Preview substitutions live, as you type! -vim.opt.inccommand = 'split' +vim.opt.inccommand = 'split' -- Preview substitutions live, as you type! +vim.opt.cursorline = true -- Show which line your cursor is on +vim.opt.scrolloff = 3 -- Minimal number of screen lines to keep above and below the cursor. --- Show which line your cursor is on -vim.opt.cursorline = true +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` --- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 3 +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) -- Restore cursor position from last file open vim.api.nvim_create_autocmd('BufRead', { @@ -155,20 +93,6 @@ vim.api.nvim_create_autocmd('BufRead', { end, }) --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - -- [[ 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' @@ -183,11 +107,6 @@ vim.opt.rtp:prepend(lazypath) -- [[ Configure and install plugins ]] -- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- -- To update plugins you can run -- :Lazy update -- @@ -353,6 +272,17 @@ require('lazy').setup({ -- }, -- }, -- pickers = {} + + --[[ layout_config = { + defaults = { + layout_strategy = 'vertical', + height = vim.o.lines, -- maximally available lines + width = vim.o.columns, -- maximally available columns + prompt_position = 'top', + -- preview_height = 0.6, -- 60% of available lines + }, + }, + --]] extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -744,10 +674,14 @@ require('lazy').setup({ -- -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + --[''] = cmp.mapping.select_next_item(), + --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, -- Scroll the documentation window [b]ack / [f]orward [''] = cmp.mapping.scroll_docs(-4), @@ -756,13 +690,6 @@ require('lazy').setup({ -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, - - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -800,6 +727,7 @@ require('lazy').setup({ { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, + { name = 'codeium' }, }, } end, @@ -845,6 +773,7 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, + { 'nvim-lualine/lualine.nvim', dependencies = { 'nvim-tree/nvim-web-devicons' }, @@ -852,6 +781,15 @@ require('lazy').setup({ require('lualine').setup() end, }, + -- Nvimtree (File Explorer) + { + 'nvim-tree/nvim-tree.lua', + lazy = true, + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + }, + { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', @@ -878,23 +816,23 @@ require('lazy').setup({ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, + -- import core settings + { import = 'core' }, + -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart -- - -- Here are some example plugins that I've included in the Kickstart repository. - -- 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 'plugins.debug', + -- require 'plugins.indent_line', + -- require 'plugins.lint', + require 'plugins.autopairs', + require 'plugins.neo-tree', + require 'plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'plugins.codeium', + require 'plugins.terraform', -- 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' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/plugins/colorscheme.lua b/lua/core/colorscheme.lua similarity index 100% rename from lua/custom/plugins/colorscheme.lua rename to lua/core/colorscheme.lua diff --git a/lua/custom/plugins/keymaps.lua b/lua/core/keymaps.lua similarity index 66% rename from lua/custom/plugins/keymaps.lua rename to lua/core/keymaps.lua index 53d5ce69..a781b1d5 100644 --- a/lua/custom/plugins/keymaps.lua +++ b/lua/core/keymaps.lua @@ -2,6 +2,17 @@ return { -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` + -- function to assist with keymapping + --[[ + function map(mode, lhs, rhs, opts) + local options = { noremap = true, silent = true } + if opts then + options = vim.tbl_extend("force", options, opts) + end + vim.keymap.set(mode, lhs, rhs, options) + end + --]] + -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch'), @@ -17,9 +28,8 @@ return { -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }), - -- Keybinds to make split navigation easier. + -- Window and buffer handling -- Use CTRL+ to switch between windows - -- -- See `:help wincmd` for a list of all window commands vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }), vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }), @@ -27,12 +37,14 @@ return { vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }), vim.keymap.set('n', '', ':bn!', { desc = 'Go to next buffer' }), vim.keymap.set('n', '', ':bp!', { desc = 'Go to previous buffer' }), + vim.keymap.set('n', 'ws', ':split', { desc = 'split window horizontally' }), + vim.keymap.set('n', 'wv', ':vsplit', { desc = 'split window vertically' }), -- terraform - vim.keymap.set('n', 'ti', ':!terraform init', { desc = 'terraform init' }), - vim.keymap.set('n', 'tv', ':!terraform validate', { desc = 'terraform validate' }), - vim.keymap.set('n', 'tp', ':!terraform plan', { desc = 'terraform plan' }), - vim.keymap.set('n', 'taa', ':!terraform apply -auto-approve', { desc = 'terraform apply' }), + vim.keymap.set('n', 'ti', ':!terraform init -no-color', { desc = 'terraform init' }), + vim.keymap.set('n', 'tv', ':!terraform validate -no-color', { desc = 'terraform validate' }), + vim.keymap.set('n', 'tp', ':!terraform plan -no-color', { desc = 'terraform plan' }), + vim.keymap.set('n', 'taa', ':!terraform apply -no-color -auto-approve', { desc = 'terraform apply' }), -- Toggles vim.keymap.set('n', 'n', ':set number!:set relativenumber!'), diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8..00000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- 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 {} diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/plugins/autopairs.lua similarity index 100% rename from lua/kickstart/plugins/autopairs.lua rename to lua/plugins/autopairs.lua diff --git a/lua/plugins/codeium.lua b/lua/plugins/codeium.lua new file mode 100644 index 00000000..5632df8c --- /dev/null +++ b/lua/plugins/codeium.lua @@ -0,0 +1,17 @@ +-- +-- Codeium +-- https://github.com/Exafunction/codeium.nvim +-- + +return { + + 'Exafunction/codeium.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'hrsh7th/nvim-cmp', + }, + event = 'BufEnter', + config = function() + require('codeium').setup {} + end, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/plugins/debug.lua similarity index 100% rename from lua/kickstart/plugins/debug.lua rename to lua/plugins/debug.lua diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua similarity index 100% rename from lua/kickstart/plugins/gitsigns.lua rename to lua/plugins/gitsigns.lua diff --git a/lua/kickstart/health.lua b/lua/plugins/health.lua similarity index 100% rename from lua/kickstart/health.lua rename to lua/plugins/health.lua diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/plugins/indent_line.lua similarity index 100% rename from lua/kickstart/plugins/indent_line.lua rename to lua/plugins/indent_line.lua diff --git a/lua/kickstart/plugins/lint.lua b/lua/plugins/lint.lua similarity index 100% rename from lua/kickstart/plugins/lint.lua rename to lua/plugins/lint.lua diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua similarity index 100% rename from lua/kickstart/plugins/neo-tree.lua rename to lua/plugins/neo-tree.lua diff --git a/lua/plugins/terraform.lua b/lua/plugins/terraform.lua new file mode 100644 index 00000000..bf6bb8d7 --- /dev/null +++ b/lua/plugins/terraform.lua @@ -0,0 +1,4 @@ +return { + 'mvaldes14/terraform.nvim', + ft = 'terraform', +}