diff --git a/init.lua b/init.lua index cfbe00d2..c0122b01 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, for 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' @@ -158,6 +158,10 @@ vim.opt.scrolloff = 10 vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') +-- Move line of code up or down +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") + -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) @@ -187,6 +191,12 @@ 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' }) +-- CUSTOM KEYBINDINGS +-- jk to enter normal mode +vim.keymap.set('i', 'jk', '') +-- Open Netrw +vim.keymap.set('n', 'rw', ':Ex!') + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -197,7 +207,7 @@ 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() + vim.highlight.on_yank { timeout = 100 } end, }) @@ -225,11 +235,23 @@ 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 + -- NVIM CHATGPT + -- { + -- 'jackMort/ChatGPT.nvim', + -- event = 'VeryLazy', + -- dependencies = { + -- 'MunifTanjim/nui.nvim', + -- 'nvim-lua/plenary.nvim', + -- 'nvim-telescope/telescope.nvim', + -- }, + -- }, + -- 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. + -- NOTE plugins -- -- This is equivalent to: -- require('Comment').setup({}) @@ -653,12 +675,13 @@ require('lazy').setup({ -- you can use this plugin to help you. It even has snippets -- for various frameworks/libraries/etc. but you will have to -- set up the ones that are useful for you. - -- 'rafamadriz/friendly-snippets', + 'rafamadriz/friendly-snippets', }, config = function() -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' + require('luasnip.loaders.from_vscode').lazy_load() luasnip.config.setup {} cmp.setup { @@ -778,18 +801,32 @@ require('lazy').setup({ { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', + 'nvim-treesitter/nvim-treesitter-context', build = ':TSUpdate', config = function() -- [[ Configure Treesitter ]] See `:help nvim-treesitter` ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc', 'javascript', 'css', 'python' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { enable = true }, indent = { enable = true }, } + -- require('treesitter-context').setup { + -- enable = true, -- Enable this plugin + -- max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + -- min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + -- line_numbers = true, + -- multiline_threshold = 20, -- Maximum number of lines to show for a single context + -- trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + -- mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' + -- separator = nil, -- Separator between context and content. Should be a single character string, like '-'. + -- -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + -- zindex = 20, -- The Z-index of the context window + -- on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching + -- } -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: