diff --git a/init.lua b/init.lua index 3784c1a18c9..503ea73120f 100644 --- a/init.lua +++ b/init.lua @@ -1,109 +1,8 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - 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. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - 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. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - 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.maplocalleader = ' ' +vim.g.have_nerd_font = true --- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false - --- [[ Setting options ]] require 'options' - --- [[ Basic Keymaps ]] require 'keymaps' - --- [[ Install `lazy.nvim` plugin manager ]] require 'lazy-bootstrap' - --- [[ Configure and install plugins ]] require 'lazy-plugins' - --- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8d7a..00000000000 --- 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/keymaps.lua b/lua/keymaps.lua index c07a08a7514..68327643268 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -1,10 +1,42 @@ --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` +-- Clear search vim.keymap.set('n', '', 'nohlsearch') +-- Save +vim.keymap.set('n', '', 'w') + +-- Exit insert +vim.keymap.set('i', 'ii', '') + +-- Auto center on search +vim.keymap.set('n', 'n', 'nzzzv') + +-- When text is wrapped, move by terminal rows, not lines, unless a count is provided. +vim.keymap.set('n', 'j', 'v:count ? "j" : "gj"', { expr = true, silent = true }) +vim.keymap.set('n', 'k', 'v:count ? "k" : "gk"', { expr = true, silent = true }) + +-- Keep selection when indenting +vim.keymap.set('v', '<', '', '>gv') + +-- Paste without yanking +--vim.keymap.set('n', 'p', '"_dP') + +-- Previous buffer +vim.keymap.set('n', '', '') + +-- Move lines up and down +vim.keymap.set('n', '', ':m .+1==') +vim.keymap.set('n', '', ':m .-2==') + +-- Redo +vim.keymap.set('n', 'U', '') + +-- Navigation +vim.keymap.set('n', 'J', '}', { desc = 'Move to next paragraph' }) +vim.keymap.set('n', 'K', '{', { desc = 'Move to previous paragraph' }) +vim.keymap.set('n', 'H', '^', { desc = 'Move to beginning of line' }) +vim.keymap.set('n', 'L', '$', { desc = 'Move to end of line' }) + -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) @@ -16,27 +48,32 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +-- Splits +vim.keymap.set('n', '-', 'split', { desc = 'Split horizontal' }) +vim.keymap.set('n', '_', 'vs', { desc = 'Split horizontal' }) +vim.keymap.set('n', '=', '=') +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) --- Keybinds to make split navigation easier. --- 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' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - --- [[ 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()` +-- Resize panes +vim.keymap.set('n', 'z>', 'resize +10', { desc = 'Increase horizontal size' }) +vim.keymap.set('n', 'z<', 'resize -10', { desc = 'Decrease horizontal size' }) +vim.keymap.set('n', 'z-', 'vertical resize +15', { desc = 'Increase vertical size' }) +vim.keymap.set('n', 'z=', 'vertical resize -15', { desc = 'Decrease vertical size' }) + +-- Gitsigns +vim.keymap.set('n', 'vn', 'Gitsigns next_hunk', { desc = 'Next hunk' }) +vim.keymap.set('n', 'vp', 'Gitsigns prev_hunk', { desc = 'Previous hunk' }) +vim.keymap.set('n', 'vr', 'Gitsigns reset_hunk', { desc = 'Reset hunk' }) +vim.keymap.set('n', 'va', 'Gitsigns stage_hunk', { desc = 'Stage hunk' }) +vim.keymap.set('n', 'vu', 'Gitsigns undo_stage_hunk', { desc = 'Undo stage hunk' }) +vim.keymap.set('n', 'vb', 'Gitsigns blame_line', { desc = 'Blame line' }) +vim.keymap.set('n', 'vP', 'Gitsigns preview_hunk', { desc = 'Preview hunk' }) +vim.keymap.set('n', 'vv', 'lua _lazygit_toggle()', { desc = 'Lazygit' }) + +-- Keep highlight vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Highlight when yanking (copying) text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), diff --git a/lua/kickstart/plugins/cmp.lua b/lua/kickstart/plugins/cmp.lua index e9ed483b75f..209ee8f29be 100644 --- a/lua/kickstart/plugins/cmp.lua +++ b/lua/kickstart/plugins/cmp.lua @@ -3,6 +3,25 @@ return { 'hrsh7th/nvim-cmp', event = 'InsertEnter', dependencies = { + { + 'zbirenbaum/copilot-cmp', + dependencies = { + { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + build = ':Copilot auth', + + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + }, + }, + }, + config = function() + require('copilot_cmp').setup() + end, + }, + -- Snippet Engine & its associated nvim-cmp source { 'L3MON4D3/LuaSnip', @@ -54,11 +73,6 @@ return { -- -- 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(), - -- Scroll the documentation window [b]ack / [f]orward [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), @@ -70,9 +84,9 @@ return { -- 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(), + [''] = 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 @@ -107,6 +121,7 @@ return { -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it group_index = 0, }, + { name = 'copilot' }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index e7fc728d85a..b07efc14ee2 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -5,7 +5,7 @@ return { cmd = { 'ConformInfo' }, keys = { { - 'f', + 'cf', function() require('conform').format { async = true, lsp_fallback = true } end, diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index bb1bb0ded3f..aae5f1651a9 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -78,6 +78,7 @@ return { -- Find references for the word under your cursor. map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gu', require('telescope.builtin').lsp_references, '[G]oto [U]sages') -- Jump to the implementation of the word under your cursor. -- Useful when your language has ways of declaring types without an actual implementation. @@ -90,11 +91,11 @@ return { -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + map('gs', require('telescope.builtin').lsp_document_symbols, '[G]oto [S]ymbols') -- Fuzzy find all the symbols in your current workspace. -- Similar to document symbols, except searches over your entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + map('gS', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[G]oto workspace [S]ymbols') -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. @@ -104,6 +105,10 @@ return { -- or a suggestion from your LSP for this to activate. map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- Opens a popup that displays documentation about the word under your cursor + -- See `:help K` for why this keymap. + map('gK', vim.lsp.buf.hover, 'Hover Documentation') + -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') diff --git a/lua/kickstart/plugins/mini.lua b/lua/kickstart/plugins/mini.lua index 3a9bdc30813..7c5fbb12111 100644 --- a/lua/kickstart/plugins/mini.lua +++ b/lua/kickstart/plugins/mini.lua @@ -15,22 +15,22 @@ return { -- - 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() -- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin - local statusline = require 'mini.statusline' + -- local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } + -- statusline.setup { use_icons = vim.g.have_nerd_font } -- You can configure sections in the statusline by overriding their -- default behavior. For example, here we set the section for -- cursor location to LINE:COLUMN ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end + -- statusline.section_location = function() + -- return '%2l:%-2v' + -- end -- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua index 159971f00e7..2e17cfb3b77 100644 --- a/lua/kickstart/plugins/telescope.lua +++ b/lua/kickstart/plugins/telescope.lua @@ -29,39 +29,37 @@ return { -- Useful for getting pretty icons, but requires a Nerd Font. { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + { + 'princejoogie/dir-telescope.nvim', + config = function() + require('dir-telescope').setup { + hidden = true, + no_ignore = true, + } + end, + }, + { + 'otavioschwanck/telescope-alternate', + config = function() + require('telescope-alternate').setup { + mappings = { + { 'src/**/*.php', { { 'tests/Unit/[1]Test.php', 'Test' } } }, -- Alternate between file and test + }, + open_only_one_with = 'current_pane', -- when just have only possible file, open it with. Can also be horizontal_split and vertical_split + } + end, + }, }, config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! + local open_with_trouble = require('trouble.sources.telescope').open - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} + defaults = { + mappings = { + i = { [''] = open_with_trouble }, + n = { [''] = open_with_trouble }, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -72,19 +70,28 @@ return { -- Enable Telescope extensions if they are installed pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') + pcall(require('telescope').load_extension, 'dir') + pcall(require('telescope').load_extension, 'telescope-alternate') -- 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', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', '?', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'a', "lua require'telescope.builtin'.find_files({ no_ignore = true })", { desc = 'Search [a]ll files' }) + vim.keymap.set('n', 'f', builtin.find_files, { desc = 'Search [F]iles' }) + vim.keymap.set('n', 'st', builtin.builtin, { desc = '[S]earch select [T]elescope' }) 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', 'F', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sg', "lua require'telescope.builtin'.live_grep({ no_ignore = true })", { desc = '[S]earch by [G]rep in all files' }) 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', 'r', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 'g', builtin.git_status, { desc = 'Search git status' }) + vim.keymap.set('n', 'sb', builtin.buffers, { desc = '[S]earch [B]uffers' }) + vim.keymap.set('n', 'i', "lua require'telescope.builtin'.oldfiles({ only_cwd = true })", { desc = '[ ] Search recent files' }) + + vim.keymap.set('n', 'sdf', 'Telescope dir find_files', { desc = '[S]earch [F]iles in [f]older' }) + vim.keymap.set('n', 'sdg', 'Telescope dir live_grep', { desc = '[S]earch [F]iles in folder' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() diff --git a/lua/kickstart/plugins/tokyonight.lua b/lua/kickstart/plugins/tokyonight.lua index 3e5e74d945b..9c55230a6b8 100644 --- a/lua/kickstart/plugins/tokyonight.lua +++ b/lua/kickstart/plugins/tokyonight.lua @@ -14,6 +14,10 @@ return { -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' + + vim.cmd 'hi HopNextKey guifg=black guibg=#00FF00' + vim.cmd 'hi HopNextKey1 guifg=black guibg=#00dfff' + vim.cmd 'hi HopNextKey2 guifg=black guibg=#2b8db3' end, }, } diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index f601d395e2a..7dce0f1579b 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -1,74 +1,236 @@ --- [[ 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 --- --- NOTE: Here is where you install your plugins. require('lazy').setup({ - -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + { 'numToStr/Comment.nvim', opts = {} }, - -- NOTE: Plugins can also be added by using a table, - -- with the first argument being the link and the following - -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - - - -- modular approach: using `require 'path/name'` will - -- include a plugin definition from file lua/path/name.lua - + -- require 'kickstart/plugins/tokyonight', require 'kickstart/plugins/gitsigns', - require 'kickstart/plugins/which-key', - require 'kickstart/plugins/telescope', - require 'kickstart/plugins/lspconfig', - require 'kickstart/plugins/conform', - require 'kickstart/plugins/cmp', - - require 'kickstart/plugins/tokyonight', - require 'kickstart/plugins/todo-comments', - require 'kickstart/plugins/mini', - require 'kickstart/plugins/treesitter', - -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the - -- init.lua. If you want these files, they are in the repository, so you can just download them and - -- place them in the correct locations. - - -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + + -- My own plugins + { 'farmergreg/vim-lastplace' }, + { 'sickill/vim-pasta' }, + -- { 'sheerun/vim-polyglot' }, + { 'alexghergh/nvim-tmux-navigation' }, + -- { + -- 'pineapplegiant/spaceduck', + -- config = function() + -- vim.cmd 'colorscheme spaceduck' -- - -- 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). + -- vim.cmd 'hi Visual guibg=#43326f' -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - - -- 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. + -- vim.cmd 'hi HopNextKey guifg=black guibg=#00FF00' -- - -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + -- vim.cmd 'hi HopNextKey guifg=black guibg=#00FF00' + -- vim.cmd 'hi HopNextKey1 guifg=black guibg=#00dfff' + -- vim.cmd 'hi HopNextKey2 guifg=black guibg=#2b8db3' + -- end, + -- }, + { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + }, + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, + }, + }, + { + 'rebelot/kanagawa.nvim', + config = function() + vim.cmd 'colorscheme kanagawa' + + vim.cmd 'hi Visual guibg=#43326f' + + vim.cmd 'hi HopNextKey guifg=black guibg=#00FF00' + + vim.cmd 'hi HopNextKey guifg=black guibg=#00FF00' + vim.cmd 'hi HopNextKey1 guifg=black guibg=#00dfff' + vim.cmd 'hi HopNextKey2 guifg=black guibg=#2b8db3' + end, + }, + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup {} + end, + }, + { + 'stevearc/oil.nvim', + opts = {}, + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('oil').setup() + + vim.keymap.set('n', '-', ':Oil', { desc = 'File explorer' }) + end, + }, + { + 'Wansmer/treesj', + keys = { 'm', 'Mj', 'Ms' }, + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + config = function() + require('treesj').setup {} + end, + }, + { + 'max397574/better-escape.nvim', + config = function() + require('better_escape').setup { + mapping = { 'ii' }, + } + end, + }, + { + 'akinsho/nvim-toggleterm.lua', + version = '*', + config = function() + require('toggleterm').setup { + direction = 'float', + } + + vim.keymap.set('n', '', "lua require('toggleterm').toggle()") + vim.keymap.set('t', '', "lua require('toggleterm').toggle()") + vim.keymap.set('t', 'ii', '', { desc = 'Exit terminal mode' }) + + local Terminal = require('toggleterm.terminal').Terminal + + local lazygit = Terminal:new { + cmd = 'lazygit', + hidden = true, + direction = 'float', + } + function _lazygit_toggle() + lazygit:toggle() + end + end, + }, + { + '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)', + }, + }, + }, + { + 'janko/vim-test', + config = function() + vim.keymap.set('n', 'tn', ':TestNearest', { desc = 'Test nearest' }) + vim.keymap.set('n', 'tf', ':TestFile', { desc = 'Test file' }) + vim.keymap.set('n', 'ts', ':TestSuite', { desc = 'Test suite' }) + vim.keymap.set('n', 'tt', ':TestLast', { desc = 'Test last' }) + vim.keymap.set('n', 'tv', ':TestVisit', { desc = 'Test visit' }) + end, + }, + { + 'smoka7/hop.nvim', + version = '*', + config = function() + require('hop').setup() + vim.keymap.set('n', 's', ':HopChar1', { desc = 'Hop to character' }) + vim.keymap.set('n', 'S', ':HopChar2', { desc = 'Hop to characters' }) + vim.keymap.set('n', 'm', ':HopLineStart', { desc = 'Hop to line start' }) + vim.keymap.set('n', 'M', ':HopLine', { desc = 'Hop to line' }) + vim.keymap.set('n', 'w', ':HopWord', { desc = 'Hop to word' }) + end, + }, + { + 'rgroli/other.nvim', + config = function() + require('other-nvim').setup { + mappings = { + pattern = '/src/.*/(.*).php$', + target = '/tests/.**/%1Test.php', + context = 'test', + }, + showMissingFiles = true, + } + vim.api.nvim_set_keymap('n', 'll', ':Other', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'lp', ':OtherSplit', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'lv', ':OtherVSplit', { noremap = true, silent = true }) + end, + }, + { + 'linrongbin16/gitlinker.nvim', + cmd = 'GitLink', + opts = {}, + keys = { + { 'vy', 'GitLink', mode = { 'n', 'v' }, desc = 'Yank git link' }, + { 'vo', 'GitLink!', mode = { 'n', 'v' }, desc = 'Open git link' }, + { 'vb', 'GitLink blame', mode = { 'n', 'v' }, desc = 'Yank git blame link' }, + { 'vB', 'GitLink!', mode = { 'n', 'v' }, desc = 'Open git blame link' }, + }, + }, + { + 'sindrets/diffview.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('diffview').setup {} + vim.keymap.set('n', 'cc', 'DiffviewOpen', { desc = 'Diffview open' }) + vim.keymap.set('n', 'cq', 'DiffviewClose', { desc = 'Diffview close' }) + vim.keymap.set('n', 'cr', 'DiffviewRefresh', { desc = 'Diffview refresh' }) + end, + }, + { + 'stevearc/dressing.nvim', + opts = {}, + }, + -- { + -- 'm4xshen/hardtime.nvim', + -- dependencies = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim' }, + -- opts = {}, + -- }, }, { ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the - -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table icons = vim.g.have_nerd_font and {} or { cmd = '⌘', config = '🛠', diff --git a/lua/options.lua b/lua/options.lua index 94ee2ed6364..58ce64ace6d 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,35 +1,39 @@ --- [[ Setting options ]] --- See `:help vim.opt` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` +-- Spaces, not tabs +vim.opt.expandtab = true +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 --- Make line numbers default +-- Disable wrapping +vim.opt.wrap = false + +-- Line numbers vim.opt.number = true --- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true --- Enable mouse mode, can be useful for resizing splits for example! -vim.opt.mouse = 'a' +-- Disable mouse mode +vim.opt.mouse = '' -- Don't show the mode, since it's already in the status line vim.opt.showmode = false -- 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. --- See `:help 'clipboard'` vim.schedule(function() vim.opt.clipboard = 'unnamedplus' end) --- Enable break indent +-- Indent vim.opt.breakindent = true +vim.opt.smartindent = true -- Save undo history +vim.opt.swapfile = false vim.opt.undofile = true +vim.opt.backup = true +vim.opt.backupdir:remove '.' --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +-- Search +vim.opt.hlsearch = true vim.opt.ignorecase = true vim.opt.smartcase = true @@ -48,8 +52,6 @@ vim.opt.splitright = true vim.opt.splitbelow = true -- Sets how neovim will display certain whitespace characters in the editor. --- See `:help 'list'` --- and `:help 'listchars'` vim.opt.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } @@ -62,4 +64,23 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +-- Command auto complete +vim.opt.wildmode = 'longest:full,full' + +-- Auto completion +vim.opt.completeopt = 'menuone,longest,preview' + +-- Disable spell checking +vim.opt.spell = false + +-- Ask for confirmation instead of erroring +vim.opt.confirm = true + +-- Sign column +vim.opt.signcolumn = 'yes:2' + +-- Ruler +vim.opt.ruler = true +vim.opt.colorcolumn = '120' + -- vim: ts=2 sts=2 sw=2 et