This commit is contained in:
MimiValsi 2024-09-10 18:03:09 +02:00
parent a22976111e
commit d106be5558
2 changed files with 199 additions and 64 deletions

243
init.lua
View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal -- 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 ]] -- [[ Setting options ]]
-- See `:help vim.opt` -- See `:help vim.opt`
@ -102,10 +102,10 @@ vim.g.have_nerd_font = false
vim.opt.number = true vim.opt.number = true
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it! -- 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! -- 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 -- Don't show the mode, since it's already in the status line
vim.opt.showmode = false vim.opt.showmode = false
@ -123,6 +123,7 @@ vim.opt.breakindent = true
-- Save undo history -- Save undo history
vim.opt.undofile = true 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 -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.opt.ignorecase = true vim.opt.ignorecase = true
@ -154,12 +155,54 @@ vim.opt.inccommand = 'split'
-- Show which line your cursor is on -- Show which line your cursor is on
vim.opt.cursorline = true 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 vim.opt.scrolloff = 10
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
-- Personnal Keymaps
-- normal mode
vim.keymap.set('n', '<leader>e', '<cmd>Ex<CR>')
vim.keymap.set('n', '<leader>ra', ':%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>', { desc = 'Replace the word under the cursor in the file' })
vim.keymap.set('n', '<leader>v', '<cmd>vsplit<CR>', { desc = 'Vertical split' })
vim.keymap.set('n', '<leader>x', '<cmd>!chmod +x %<CR>', { desc = 'Make the current buffer/file executable' })
vim.keymap.set('n', ';', ':', { desc = 'Replace : by ;' })
vim.keymap.set('n', 'Q', ':noh<CR>')
vim.keymap.set('n', '<leader>w', ':w<CR>')
-- insert mode
vim.keymap.set('i', '<C-h>', '<left>')
vim.keymap.set('i', '<C-j>', '<down>')
vim.keymap.set('i', '<C-k>', '<up>')
vim.keymap.set('i', '<C-l>', '<right>')
-- while in insert mode, go to the start of line
vim.keymap.set('i', '<C-b>', '<ESC>^i')
-- while in insert mode, go to end of line
vim.keymap.set('i', '<C-e>', '<End>')
-- better escape insert mode
vim.keymap.set('i', 'jk', '<Esc>')
-- visual mode
-- better escape visual mode
vim.keymap.set('v', 'sd', '<Esc>')
-- move the highlighted line(s) up and indent if needed
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=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 '<-2<CR>gv=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 <Esc> in normal mode -- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch` -- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
@ -204,6 +247,16 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end, 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 ]] -- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' 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
end ---@diagnostic disable-next-line: undefined-field end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath) 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. -- NOTE: Here is where you install your plugins.
require('lazy').setup({ require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). -- 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. -- 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', '<leader>a', function()
harpoon:list():add()
end)
map('n', '<C-h>', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
map('n', '<leader>1', function()
harpoon:list():select(1)
end, { desc = '[Harpoon] Go to first buffer saved' })
map('n', '<leader>2', function()
harpoon:list():select(2)
end, { desc = '[Harpoon] Go to second buffer saved' })
map('n', '<leader>3', function()
harpoon:list():select(3)
end, { desc = '[Harpoon] Go to third buffer saved' })
map('n', '<leader>4', function()
harpoon:list():select(4)
end, { desc = '[Harpoon] Go to forth buffer saved' })
map('n', '<leader>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 -- Here is a more advanced example where we pass configuration
-- options to `gitsigns.nvim`. This is equivalent to the following Lua: -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
-- require('gitsigns').setup({ ... }) -- require('gitsigns').setup({ ... })
@ -245,15 +326,6 @@ require('lazy').setup({
-- See `:help gitsigns` to understand what the configuration keys do -- See `:help gitsigns` to understand what the configuration keys do
{ -- Adds git related signs to the gutter, as well as utilities for managing changes { -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim', '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. -- NOTE: Plugins can also be configured to run Lua code when they are loaded.
@ -318,7 +390,7 @@ require('lazy').setup({
{ '<leader>d', group = '[D]ocument' }, { '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' }, { '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' }, { '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' }, -- { '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' }, { '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, { '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
}, },
@ -386,8 +458,12 @@ require('lazy').setup({
-- mappings = { -- mappings = {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' }, -- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- }, -- },
pickers = {
find_files = {
hidden = true,
},
},
-- }, -- },
-- pickers = {}
extensions = { extensions = {
['ui-select'] = { ['ui-select'] = {
require('telescope.themes').get_dropdown(), require('telescope.themes').get_dropdown(),
@ -413,13 +489,13 @@ require('lazy').setup({
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Slightly advanced example of overriding default behavior and theme -- Slightly advanced example of overriding default behavior and theme
vim.keymap.set('n', '<leader>/', function() -- vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc. -- -- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { -- builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10, -- winblend = 10,
previewer = false, -- previewer = false,
}) -- })
end, { desc = '[/] Fuzzily search in current buffer' }) -- end, { desc = '[/] Fuzzily search in current buffer' })
-- It's also possible to pass additional configuration options. -- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys -- 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. -- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project. -- Similar to document symbols, except searches over your entire project.
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- Rename the variable under your cursor. -- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc. -- 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. -- - 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/ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = { local servers = {
-- clangd = {}, clangd = {
-- gopls = {}, 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 = {}, -- pyright = {},
-- rust_analyzer = {}, -- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- ... 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 -- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional -- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones. -- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true } local disable_filetypes = {}
local lsp_format_opt local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = 'never' lsp_format_opt = 'never'
@ -699,6 +796,7 @@ require('lazy').setup({
end, end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
c = { 'clangd' },
-- Conform can also run multiple formatters sequentially -- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" }, -- python = { "isort", "black" },
-- --
@ -796,16 +894,16 @@ require('lazy').setup({
-- --
-- <c-l> will move you to the right of each of the expansion locations. -- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards. -- <c-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function() ['<Tab>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
end end
end, { 'i', 's' }), end, { 's' }),
['<C-h>'] = cmp.mapping(function() ['<S-Tab>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then if luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
end end
end, { 'i', 's' }), end, { 's' }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
@ -824,21 +922,50 @@ require('lazy').setup({
end, end,
}, },
{ -- You can easily change to a different colorscheme. -- { -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then -- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is. -- 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`. -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'folke/tokyonight.nvim', -- 'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins. -- priority = 1000, -- Make sure to load this before all the other start plugins.
init = function() -- init = function()
-- Load the colorscheme here. -- -- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load -- -- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. -- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night' -- 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: { -- Modified gruvbox
vim.cmd.hi 'Comment gui=none' '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, end,
}, },
@ -888,7 +1015,7 @@ require('lazy').setup({
main = 'nvim-treesitter.configs', -- Sets main module to use for opts main = 'nvim-treesitter.configs', -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter` -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = { 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 -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,
highlight = { highlight = {
@ -898,7 +1025,7 @@ require('lazy').setup({
-- the list of additional_vim_regex_highlighting and disabled languages for indent. -- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' }, 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 -- 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: -- 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.debug',
-- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint', require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs', require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree', -- 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` -- 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. -- 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. -- 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` -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' }, { import = 'custom.plugins' },
}, { }, {
ui = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you are using a Nerd Font: set icons to an empty table which will use the

View File

@ -2,4 +2,12 @@
-- I promise not to create any merge conflicts in this directory :) -- I promise not to create any merge conflicts in this directory :)
-- --
-- See the kickstart.nvim README for more information -- See the kickstart.nvim README for more information
return {} return {
{
'brenoprata10/nvim-highlight-colors',
config = function()
require('nvim-highlight-colors').setup {}
end,
},
}