diff --git a/init.lua b/init.lua index cfbe00d..2b18896 100644 --- a/init.lua +++ b/init.lua @@ -63,7 +63,7 @@ Kickstart Guide: 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, + MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, which is very useful when you're not sure exactly what you're looking for. I have left several `:help X` comments throughout the init.lua @@ -154,6 +154,9 @@ vim.opt.scrolloff = 10 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +-- duplicate command mode without need for shift +vim.keymap.set('n', ';', ':', { desc = 'enter command mode', nowait = true }) + -- Set highlight on search, but clear on pressing in normal mode vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') @@ -187,6 +190,36 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +vim.keymap.set('n', '', 'zz', { desc = 'scroll down centered' }) +vim.keymap.set('n', '', 'zz', { desc = 'scroll down centered' }) + +vim.keymap.set('n', 'J', 'mzJ`z', { desc = 'Join lines keep cursor position' }) + +vim.keymap.set('n', 'n', 'nzzzv', { desc = 'search forward centered' }) +vim.keymap.set('n', 'N', 'Nzzzv', { desc = 'search backward centered' }) + +vim.keymap.set('n', 'y', '"+y', { desc = 'yank to system clipboard' }) +vim.keymap.set('n', 'Y', '"+Y', { desc = 'yank lines to system clipboard' }) +vim.keymap.set('n', 'd', '_d', { desc = 'delete to void register' }) +vim.keymap.set('n', '', 'silent !tmux neww tmux-sessionizer', { desc = 'switch projects when using tmux' }) +vim.keymap.set('n', 's', ':%s///gI', { desc = 'replace word under cursor' }) + +vim.keymap.set('n', 'cm', ':%s/\\r$//g', { desc = 'Remove CR from end of line' }) + +vim.keymap.set('n', 'x', '!chmod +x %', { desc = 'set execute bit on open script' }) + +vim.keymap.set('n', 'x', '"_x', { desc = 'del char keep clip' }) +vim.keymap.set('n', 'X', '"_X', { desc = 'del char keep clip' }) + +vim.keymap.set('n', 'cr', function() + require('nvchad.renamer').open() +end, { desc = 'LSP Rename' }) +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move selected text down' }) +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move selected text up' }) +vim.keymap.set('v', '', '', { desc = 'exit vertical edit mode' }) +vim.keymap.set('i', 'jk', '') +vim.keymap.set('t', 'jk', '') + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -234,7 +267,7 @@ require('lazy').setup({ -- This is equivalent to: -- require('Comment').setup({}) - -- "gc" to comment visual regions/lines + -- "gc" to com ent visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, -- Here is a more advanced example where we pass configuration @@ -320,7 +353,7 @@ require('lazy').setup({ }, 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 + -- it can fuzzy find! It's more than just a "fi e 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: @@ -328,13 +361,6 @@ require('lazy').setup({ -- -- 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! @@ -532,10 +558,9 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + clangd = {}, + cssls = {}, + gopls = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- Some languages (like typescript) have entire language plugins that can be useful: @@ -544,7 +569,6 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- - lua_ls = { -- cmd = {...}, -- filetypes { ...}, @@ -571,6 +595,11 @@ require('lazy').setup({ }, }, }, + html = {}, + htmx = {}, + pyright = {}, + rust_analyzer = {}, + yamlls = {}, } -- Ensure the servers and tools above are installed @@ -624,6 +653,13 @@ require('lazy').setup({ }, }, + { -- copilot + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + event = 'InsertEnter', + opts = {}, + }, + { -- Autocompletion 'hrsh7th/nvim-cmp', event = 'InsertEnter', @@ -654,6 +690,9 @@ require('lazy').setup({ -- for various frameworks/libraries/etc. but you will have to -- set up the ones that are useful for you. -- 'rafamadriz/friendly-snippets', + + -- add copilot support + 'hrsh7th/cmp-copilot', }, config = function() -- See `:help cmp` @@ -710,9 +749,13 @@ require('lazy').setup({ }, sources = { { name = 'nvim_lsp' }, + { name = 'copilot' }, { name = 'luasnip' }, { name = 'path' }, }, + experimental = { + ghost_text = true, + }, } end, },