diff --git a/init.lua b/init.lua index fd36919c23e..753948962b8 100644 --- a/init.lua +++ b/init.lua @@ -1,40 +1,3 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== - -Kickstart.nvim is *not* a distribution. - -Kickstart.nvim is a template 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 should start exploring, configuring and tinkering to - explore Neovim! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example: - - https://learnxinyminutes.com/docs/lua/ - - And then you can explore or search through `:help lua-guide` - - -Kickstart Guide: - -I have left several `:help X` comments throughout the init.lua -You should run that command and read that help section for more information. - -In addition, I have some `NOTE:` items throughout the file. -These are for you, the reader to help 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 nvim config. - -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 required (otherwise wrong leader will be used) @@ -107,6 +70,9 @@ require('lazy').setup({ }, }, + -- Plugin to autopair brackets + { 'windwp/nvim-autopairs', event = 'InsertEnter', opts = {} }, + -- Useful plugin to show you pending keybinds. { 'folke/which-key.nvim', opts = {} }, { @@ -124,18 +90,20 @@ require('lazy').setup({ on_attach = function(bufnr) vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) - vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) + vim.keymap.set('n', 'rh', require('gitsigns').reset_hunk, { buffer = bufnr, desc = '[R]eset [H]unk' }) + vim.keymap.set('n', 'vh', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Pre[v]iew [H]unk' }) end, }, }, - { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', + -- theme + { + "catppuccin/nvim", + name = "catppuccin", priority = 1000, config = function() - vim.cmd.colorscheme 'onedark' - end, + vim.cmd.colorscheme 'catppuccin' -- 'catppuccin-latte', 'catppuccin-frappe', 'catppuccin-macchiato', 'catppuccin-mocha' + end }, { @@ -145,7 +113,7 @@ require('lazy').setup({ opts = { options = { icons_enabled = false, - theme = 'onedark', + theme = 'auto', component_separators = '|', section_separators = '', }, @@ -210,7 +178,7 @@ require('lazy').setup({ -- NOTE: You can change these options as you wish! -- Set highlight on search -vim.o.hlsearch = false +vim.o.hlsearch = true -- Make line numbers default vim.wo.number = true @@ -219,9 +187,30 @@ vim.wo.number = true vim.o.mouse = 'a' -- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.o.clipboard = 'unnamedplus' +vim.keymap.set({'n', 'v'}, 'y', '"+y', { desc = 'Yank to system clipboard' }) +vim.keymap.set({'n', 'v'}, 'p', '"+p', { desc = 'Paste from system clipboard' }) +vim.keymap.set({'n', 'v'}, 'P', '"+P', { desc = 'Paste from system clipboard' }) +vim.keymap.set('n', 'yy', '"+yy', { desc = 'Yank line to system clipboard' }) +vim.keymap.set('n', 'Y', '"+y$', { desc = 'Yank to end of line to system clipboard' }) +vim.keymap.set('v', 'Y', '"+Y', { desc = 'Yank highlighted lines to system clipboard' }) + +-- Escape terminal mode +vim.keymap.set('t', '', '', { desc = 'Escape terminal mode'}) + +-- Use ALT+{h,j,k,l} to navigate windows from any mode (see :help terminal) +vim.keymap.set('t', '', 'h') +vim.keymap.set('t', '', 'j') +vim.keymap.set('t', '', 'k') +vim.keymap.set('t', '', 'l') +vim.keymap.set('i', '', 'h') +vim.keymap.set('i', '', 'j') +vim.keymap.set('i', '', 'k') +vim.keymap.set('i', '', 'l') +vim.keymap.set('n', '', 'h') +vim.keymap.set('n', '', 'j') +vim.keymap.set('n', '', 'k') +vim.keymap.set('n', '', 'l') -- Enable break indent vim.o.breakindent = true @@ -247,6 +236,19 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true +-- Think these are set automatically by a plugin instead +-- vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true + +vim.o.scrolloff = 8 + +-- Folding with treesitter +vim.o.foldmethod = 'expr' +vim.o.foldexpr = 'nvim_treesitter#foldexpr()' +vim.o.foldenable = false -- start with all folds open +vim.o.foldlevel = 99 + -- [[ Basic Keymaps ]] -- Keymaps for better default experience @@ -268,6 +270,18 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) +require('Comment').setup({ + ignore = '^$', + toggler = { + line = 'cc', + block = 'bc', + }, + opleader = { + line = 'c', + block = 'b', + }, +}) + -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { @@ -306,7 +320,7 @@ 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', 'vimdoc', 'vim', 'c_sharp' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, @@ -425,11 +439,11 @@ end -- Add any additional override configuration in the following tables. They will be passed to -- the `settings` field of the server config. You must look up that documentation yourself. local servers = { - -- clangd = {}, - -- gopls = {}, + clangd = {}, + gopls = {}, -- pyright = {}, -- rust_analyzer = {}, - -- tsserver = {}, + tsserver = {}, lua_ls = { Lua = {