diff --git a/init.lua b/init.lua index 13c8143d..47df103a 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.opt` @@ -102,15 +102,15 @@ vim.g.have_nerd_font = false 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' +vim.opt.mouse = 'i' -- Don't show the mode, since it's already in the status line vim.opt.showmode = false --- Sync clipboard between OS and Neovim. +-- 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'` @@ -123,6 +123,7 @@ vim.opt.breakindent = true -- Save undo history vim.opt.undofile = true +vim.opt.undodir = os.getenv 'HOME' .. '/.vim/undodir' -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term vim.opt.ignorecase = true @@ -154,12 +155,54 @@ vim.opt.inccommand = 'split' -- Show which line your cursor is on vim.opt.cursorline = true --- Minimal number of screen lines to keep above and below the cursor. +-- Minimal number of screen lines tExo keep above and below the cursor. vim.opt.scrolloff = 10 - -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +-- Personnal Keymaps +-- normal mode +vim.keymap.set('n', 'e', 'Ex') + +vim.keymap.set('n', 'ra', ':%s/\\<\\>//gI', { desc = 'Replace the word under the cursor in the file' }) + +vim.keymap.set('n', 'v', 'vsplit', { desc = 'Vertical split' }) + +vim.keymap.set('n', 'x', '!chmod +x %', { desc = 'Make the current buffer/file executable' }) + +vim.keymap.set('n', ';', ':', { desc = 'Replace : by ;' }) + +vim.keymap.set('n', 'Q', ':noh') + +vim.keymap.set('n', 'w', ':w') + +-- insert mode +vim.keymap.set('i', '', '') +vim.keymap.set('i', '', '') +vim.keymap.set('i', '', '') +vim.keymap.set('i', '', '') + +-- while in insert mode, go to the start of line +vim.keymap.set('i', '', '^i') + +-- while in insert mode, go to end of line +vim.keymap.set('i', '', '') + +-- better escape insert mode +vim.keymap.set('i', 'jk', '') + +-- visual mode + +-- better escape visual mode +vim.keymap.set('v', 'sd', '') + +-- move the highlighted line(s) up and indent if needed +vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'make the selected hightlighted line and go up one line, indent if possible and highlight it again' }) + +-- move te highlighted line(s) down and indent if needed +vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'make the selected hightlighted line and go down one line, indent if possible and highlight it again' }) +-- end personnal keymaps + -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') @@ -204,6 +247,16 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- [[ 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 +-- -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -215,17 +268,6 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) - --- [[ 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). @@ -238,6 +280,45 @@ require('lazy').setup({ -- Use `opts = {}` to force a plugin to be loaded. -- + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + + init = function() + local harpoon = require 'harpoon' + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + local map = vim.keymap.set + + map('n', 'a', function() + harpoon:list():add() + end) + map('n', '', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + map('n', '1', function() + harpoon:list():select(1) + end, { desc = '[Harpoon] Go to first buffer saved' }) + map('n', '2', function() + harpoon:list():select(2) + end, { desc = '[Harpoon] Go to second buffer saved' }) + map('n', '3', function() + harpoon:list():select(3) + end, { desc = '[Harpoon] Go to third buffer saved' }) + map('n', '4', function() + harpoon:list():select(4) + end, { desc = '[Harpoon] Go to forth buffer saved' }) + map('n', '5', function() + harpoon:list():select(5) + end, { desc = '[Harpoon] Go to forth buffer saved' }) + end, + }, + -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following Lua: -- require('gitsigns').setup({ ... }) @@ -245,15 +326,6 @@ require('lazy').setup({ -- See `:help gitsigns` to understand what the configuration keys do { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. @@ -318,7 +390,7 @@ require('lazy').setup({ { 'd', group = '[D]ocument' }, { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, - { 'w', group = '[W]orkspace' }, + -- { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, @@ -386,8 +458,12 @@ require('lazy').setup({ -- mappings = { -- i = { [''] = 'to_fuzzy_refine' }, -- }, + pickers = { + find_files = { + hidden = true, + }, + }, -- }, - -- pickers = {} extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -413,13 +489,13 @@ require('lazy').setup({ vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) + -- vim.keymap.set('n', '/', function() + -- -- You can pass additional configuration to Telescope to change the theme, layout, etc. + -- builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + -- winblend = 10, + -- previewer = false, + -- }) + -- end, { desc = '[/] Fuzzily search in current buffer' }) -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys @@ -533,7 +609,7 @@ require('lazy').setup({ -- 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('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. @@ -605,8 +681,29 @@ 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 = {}, + clangd = { + cmd = { 'clangd' }, + filetypes = { 'c', 'cpp' }, + root_dir = function(fname) + return require('lspconfig.util').root_pattern '.clang.format'(fname) + end, + }, + + gopls = { + settings = { + gopls = { + experimentalPostfixCompletions = true, + analyses = { + unusedparams = true, + shadow = true, + }, + staticcheck = true, + }, + }, + init_options = { + usePlaceholders = true, + }, + }, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -685,7 +782,7 @@ require('lazy').setup({ -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } + local disable_filetypes = {} local lsp_format_opt if disable_filetypes[vim.bo[bufnr].filetype] then lsp_format_opt = 'never' @@ -699,6 +796,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + c = { 'clangd' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -796,16 +894,16 @@ require('lazy').setup({ -- -- will move you to the right of each of the expansion locations. -- is similar, except moving you backwards. - [''] = cmp.mapping(function() + [''] = cmp.mapping(function() if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end - end, { 'i', 's' }), - [''] = cmp.mapping(function() + end, { 's' }), + [''] = cmp.mapping(function() if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end - end, { 'i', 's' }), + end, { 's' }), -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps @@ -824,21 +922,50 @@ require('lazy').setup({ end, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- 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', - priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() - -- 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' + -- { -- You can easily change to a different colorscheme. + -- Change the name of the colorscheme plugin below, and then + -- 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', + -- priority = 1000, -- Make sure to load this before all the other start plugins. + -- init = function() + -- -- 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' + -- + -- -- You can configure highlights by doing something like: + -- vim.cmd.hi 'Comment gui=none' + -- end, + -- }, - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' + { -- Modified gruvbox + 'ellisonleao/gruvbox.nvim', + + priority = 1000, + init = function() + require('gruvbox').setup { + contrast = 'hard', + bold = false, + palette_overrides = { + -- 6th shade from default + dark0_hard = '#0e1010', + + -- 4th shade from the default (See color-hex.com) + bright_purple = '#935d6c', + dark1 = '#2a2725', + bright_red = '#af3324', + bright_yellow = '#af8420', + bright_orange = '#b15911', + bright_green = '#80821a', + bright_aqua = '#638656', + light1 = '#a4997c', + }, + } + + vim.o.background = 'dark' + vim.cmd.colorscheme 'gruvbox' end, }, @@ -888,7 +1015,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'go', 'javascript', 'css' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -898,7 +1025,7 @@ require('lazy').setup({ -- the list of additional_vim_regex_highlighting and disabled languages for indent. additional_vim_regex_highlighting = { 'ruby' }, }, - indent = { enable = true, disable = { 'ruby' } }, + -- indent = { enable = true, disable = { 'ruby', 'c' } }, }, -- 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: @@ -919,17 +1046,17 @@ require('lazy').setup({ -- -- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.lint', + 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. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..145d1dac 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,12 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'brenoprata10/nvim-highlight-colors', + + config = function() + require('nvim-highlight-colors').setup {} + end, + }, +}