diff --git a/.gitignore b/.gitignore index 005b535b606..413895a843d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ tags test.sh .luarc.json nvim +lazy-lock.json spell/ -lazy-lock.json diff --git a/init.lua b/init.lua index b98ffc6198a..79043e07d96 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' 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 -- [[ Setting options ]] -- See `:help vim.o` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.o.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.o.relativenumber = true +vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = 'a' @@ -176,6 +176,17 @@ vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- Move highlighted lines up and down +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '>-2gv=gv") + +-- Center search results +vim.keymap.set('n', 'n', 'nzz') +vim.keymap.set('n', 'N', 'Nzz') +vim.keymap.set('n', 'G', 'Gzz') +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') + -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. @@ -249,6 +260,10 @@ require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + -- 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. @@ -284,6 +299,19 @@ require('lazy').setup({ }, }, + { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = 'oxocarbon', + -- component_separators = '|', + -- section_separators = '', + }, + }, + }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- -- This is often very useful to both group configuration, as well as handle @@ -653,6 +681,9 @@ require('lazy').setup({ return diagnostic_message[diagnostic.severity] end, }, + virtual_lines = { + current_line = true, + }, } -- LSP servers and clients are able to communicate to each other what features they support. @@ -799,12 +830,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, opts = {}, }, @@ -835,7 +866,7 @@ require('lazy').setup({ -- : Toggle signature help -- -- See :h blink-cmp-config-keymap for defining your own keymap - preset = 'default', + preset = 'enter', -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps @@ -881,20 +912,14 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + 'nyoom-engineering/oxocarbon.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. config = function() - ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { - styles = { - comments = { italic = false }, -- Disable italics in comments - }, - } - -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'oxocarbon' + vim.opt.background = 'dark' end, }, @@ -974,17 +999,17 @@ require('lazy').setup({ -- 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.indent_line', -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- 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' }, + { 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/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..ae5f397e0c3 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,106 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + -- Undotree for saving file editing history + 'mbbill/undotree', + + -- TS Autotag for html auto tag close + 'windwp/nvim-ts-autotag', + + -- Better jinja2 support + 'HiPhish/jinja.vim', + + -- Navigation integration for tmux + 'christoomey/vim-tmux-navigator', + + -- More convenient way to use terminal from neovim + { + 'akinsho/toggleterm.nvim', + config = function() + require('toggleterm').setup { + size = function(term) + if term.direction == 'horizontal' then + return 15 + elseif term.direction == 'vertical' then + return vim.o.columns * 0.4 + end + end, + open_mapping = 'tt', + insert_mappings = false, + direction = 'float', + shell = '/usr/bin/fish', + } + end, + }, + + -- Harpoon for fast navigation within a project + { + 'theprimeagen/harpoon', + config = function() + local mark = require 'harpoon.mark' + local ui = require 'harpoon.ui' + + vim.keymap.set('n', '', mark.add_file) + vim.keymap.set('n', '', ui.toggle_quick_menu) + + vim.keymap.set('n', '', function() + ui.nav_file(1) + end) + vim.keymap.set('n', '', function() + ui.nav_file(2) + end) + vim.keymap.set('n', '', function() + ui.nav_file(3) + end) + end, + }, + + -- Oil.nvim for directory manipulation + { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + -- Optional dependencies + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + config = function() + require('oil').setup() + vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) + end, + }, + + { + 'nvim-neorg/neorg', + lazy = false, + version = '*', + config = function() + require('neorg').setup { + load = { + ['core.defaults'] = {}, + ['core.concealer'] = {}, + ['core.dirman'] = { + config = { + workspaces = { + notes = '~/notes', + }, + default_workspace = 'notes', + }, + }, + ['core.summary'] = {}, + }, + } + + vim.wo.foldlevel = 99 + vim.wo.conceallevel = 2 + end, + }, + + -- INFO: Previously used, now disabled plugins + + -- Github copilot + -- 'github/copilot.vim', +} diff --git a/lua/custom/plugins/rustaceanvim.lua b/lua/custom/plugins/rustaceanvim.lua new file mode 100644 index 00000000000..385c03de152 --- /dev/null +++ b/lua/custom/plugins/rustaceanvim.lua @@ -0,0 +1,5 @@ +return { + 'mrcjkb/rustaceanvim', + version = '^6', + lazy = false, +} diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua index 386d392e7ad..bbdbd3fef04 100644 --- a/lua/kickstart/plugins/autopairs.lua +++ b/lua/kickstart/plugins/autopairs.lua @@ -4,5 +4,49 @@ return { 'windwp/nvim-autopairs', event = 'InsertEnter', - opts = {}, + config = function() + local npairs = require 'nvim-autopairs' + npairs.setup {} + local Rule = require 'nvim-autopairs.rule' + local cond = require 'nvim-autopairs.conds' + + -- INFO: Add 'ins' inside 'a1' and 'a2' for specified language(s) + + local function rule2(a1, ins, a2, lang) + npairs.add_rule(Rule(ins, ins, lang) + :with_pair(function(opts) + return a1 .. a2 == opts.line:sub(opts.col - #a1, opts.col + #a2 - 1) + end) + :with_move(cond.none()) + :with_cr(cond.none()) + :with_del(function(opts) + local col = vim.api.nvim_win_get_cursor(0)[2] + return a1 .. ins .. ins .. a2 == opts.line:sub(col - #a1 - #ins + 1, col + #ins + #a2) -- insert only works for #ins == 1 anyway + end)) + end + + rule2('{', '%', '}', { 'html', 'htmldjango', 'jinja' }) + rule2('{%', ' ', '%}', { 'html', 'htmldjango', 'jinja' }) + rule2('{', ':', '}', 'norg') + rule2('(', ' ', ')') + rule2('[', ' ', ']') + rule2('{', ' ', '}') + + -- INFO: Add autopairs <> mainly for rust types and generics + npairs.add_rule(Rule('<', '>', { + -- if you use nvim-ts-autotag, you may want to exclude these filetypes from this rule + -- so that it doesn't conflict with nvim-ts-autotag + '-html', + '-javascriptreact', + '-typescriptreact', + }):with_pair( + -- regex will make it so that it will auto-pair on + -- `a<` but not `a <` + -- The `:?:?` part makes it also + -- work on Rust generics like `some_func::()` + cond.before_regex('%a+:?:?$', 3) + ):with_move(function(opts) + return opts.char == '>' + end)) + end, }