From 2a102a0ee14ccbc67a4e7f7dacc5ae9ffbbe43ab Mon Sep 17 00:00:00 2001 From: Albin Chaboissier Date: Wed, 8 Apr 2026 22:34:08 +0200 Subject: [PATCH] initial commit --- init.lua | 5 ++ lua/config.lua | 82 +++++++++++++++++++++++ lua/plugins/cmp.lua | 127 ++++++++++++++++++++++++++++++++++++ lua/plugins/colorscheme.lua | 7 ++ lua/plugins/flash.lua | 19 ++++++ lua/plugins/init.lua | 10 +++ lua/plugins/lsp.lua | 41 ++++++++++++ lua/plugins/lsplines.lua | 4 ++ lua/plugins/mini.lua | 6 ++ lua/plugins/multicursor.lua | 87 ++++++++++++++++++++++++ lua/plugins/oil.lua | 18 +++++ lua/plugins/telescope.lua | 36 ++++++++++ lua/plugins/treesitter.lua | 81 +++++++++++++++++++++++ nvim-pack-lock.json | 73 +++++++++++++++++++++ 14 files changed, 596 insertions(+) create mode 100644 init.lua create mode 100644 lua/config.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/colorscheme.lua create mode 100644 lua/plugins/flash.lua create mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lsplines.lua create mode 100644 lua/plugins/mini.lua create mode 100644 lua/plugins/multicursor.lua create mode 100644 lua/plugins/oil.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 nvim-pack-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e8b8e83 --- /dev/null +++ b/init.lua @@ -0,0 +1,5 @@ +require("config") +require("plugins") + +require('vim._core.ui2').enable() + diff --git a/lua/config.lua b/lua/config.lua new file mode 100644 index 0000000..1e23a0b --- /dev/null +++ b/lua/config.lua @@ -0,0 +1,82 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Prevents showing extra messages when using completion +vim.opt.shortmess:append("c") + +-- Sets the height of the command line area at the bottom +vim.opt.cmdheight = 2 + +-- Displays the line number for the current line +vim.opt.number = true + +-- Displays line numbers relative to the current cursor position +vim.opt.relativenumber = true + +-- Time in milliseconds to wait for a mapped sequence to complete +vim.opt.timeoutlen = 500 + +-- Time in milliseconds of inactivity before calling CursorHold or writing to swap +vim.opt.updatetime = 4000 + +-- Ignores case when searching patterns +vim.opt.ignorecase = true + +-- Automatically switches to case-sensitive search if a capital letter is used +vim.opt.smartcase = true + +-- Enables 24-bit RGB colors in the terminal +vim.opt.termguicolors = true + +-- Configures the behavior of the insert mode completion menu +vim.opt.completeopt = "menu,menuone,noselect,popup" + +-- Number of spaces that a character represents +vim.opt.tabstop = 4 + +-- Number of spaces to use for each step of automatic indentation +vim.opt.shiftwidth = 4 + +-- Number of spaces that a counts for during editing operations +vim.opt.softtabstop = 4 + +-- Converts tabs into spaces when typing +vim.opt.expandtab = true + +-- Automatically inserts an extra level of indentation in some cases +vim.opt.smartindent = true + +-- Makes insert 'shiftwidth' number of spaces at the start of a line +vim.opt.smarttab = true + +-- Incremental and highlight search +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.signcolumn = "yes" + +-- Transparent terminal +vim.cmd("highlight Normal ctermbg=NONE") +vim.cmd("highlight NonText ctermbg=NONE") + +-- ****** +-- REMAPS +-- ****** + +-- netrw +vim.keymap.set("n", "pv", vim.cmd.Ex) + +-- move +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- del line +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") + +-- Center when moving +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + + diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..25e73bc --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,127 @@ +-- To use mini icons with blink.cmp +local function get_mini_icon(ctx) + if ctx.source_name == "Path" then + local is_unknown_type = vim.tbl_contains( + { "link", "socket", "fifo", "char", "block", "unknown" }, + ctx.item.data.type + ) + local mini_icon, mini_hl, _ = require("mini.icons").get( + is_unknown_type and "os" or ctx.item.data.type, + is_unknown_type and "" or ctx.label + ) + if mini_icon then + return mini_icon, mini_hl + end + end + local mini_icon, mini_hl, _ = require("mini.icons").get("lsp", ctx.kind) + return mini_icon, mini_hl +end + +vim.api.nvim_create_autocmd('PackChanged', { + callback = function(ev) + print("mqsidjfmqoisdfj") + if ev.data.spec.name == 'blink.cmp' then + local res = vim.system({ 'cargo', 'build', '--release' }, { cwd = ev.data.path }) + if vim.v.shell_error ~= 0 then + vim.notify('Failed to compile blink.cmp: ' .. res, vim.log.levels.ERROR) + else + vim.notify('Successfully compiled blink.cmp', vim.log.levels.INFO) + end + end + end, +}) + +vim.pack.add({ + "https://github.com/xzbdmw/colorful-menu.nvim", + { src = "https://github.com/saghen/blink.cmp", verion = vim.version.range("1.x") }, +}) + +-- You don't need to set these options. +require("colorful-menu").setup({ + ls = { + ["rust-analyzer"] = { + -- Such as (as Iterator), (use std::io). + extra_info_hl = "@comment", + -- Similar to the same setting of gopls. + align_type_to_right = true, + -- See https://github.com/xzbdmw/colorful-menu.nvim/pull/36 + preserve_type_when_truncate = true, + }, + clangd = { + -- Such as "From ". + extra_info_hl = "@comment", + -- Similar to the same setting of gopls. + align_type_to_right = true, + -- the hl group of leading dot of "•std::filesystem::permissions(..)" + import_dot_hl = "@comment", + -- See https://github.com/xzbdmw/colorful-menu.nvim/pull/36 + preserve_type_when_truncate = true, + }, + -- If true, try to highlight "not supported" languages. + fallback = true, + -- this will be applied to label description for unsupport languages + fallback_extra_info_hl = "@comment", + }, + -- If the built-in logic fails to find a suitable highlight group for a label, + -- this highlight is applied to the label. + fallback_highlight = "@variable", + -- If provided, the plugin truncates the final displayed text to + -- this width (measured in display cells). Any highlights that extend + -- beyond the truncation point are ignored. When set to a float + -- between 0 and 1, it'll be treated as percentage of the width of + -- the window: math.floor(max_width * vim.api.nvim_win_get_width(0)) + -- Default 60. + max_width = 60, +}) + +vim.api.nvim_set_hl(0, "BlinkCmpMenu", { link = "NormalFloat" }) +vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { link = "FloatBorder" }) +vim.api.nvim_set_hl(0, "BlinkCmpDoc", { link = "NormalFloat" }) +vim.api.nvim_set_hl(0, "BlinkCmpDocBorder", { link = "FloatBorder" }) + +require("blink.cmp").setup({ + keymap = { preset = "super-tab" }, + signature = { enabled = true }, + sources = { + default = { "lsp", "path", "buffer" }, + }, + + completion = { + documentation = { auto_show = false }, + menu = { + -- border = "single", + draw = { + -- We don't need label_description now because label and label_description are already + -- combined together in label by colorful-menu.nvim. + columns = { { "kind_icon" }, { "label", gap = 1 } }, + components = { + label = { + text = function(ctx) + return require("colorful-menu").blink_components_text(ctx) + end, + highlight = function(ctx) + return require("colorful-menu").blink_components_highlight(ctx) + end, + }, + kind_icon = { + text = function(ctx) + local mini_icon, _mini_hl = get_mini_icon(ctx) + return mini_icon + end, + highlight = function(ctx) + local _mini_icon, mini_hl = get_mini_icon(ctx) + return mini_hl + end, + }, + kind = { + -- (optional) use highlights from mini.icons + highlight = function(ctx) + local _mini_icon, mini_hl = get_mini_icon(ctx) + return mini_hl + end, + }, + }, + }, + }, + }, +}) diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..1043ef7 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,7 @@ +vim.pack.add({"https://github.com/rktjmp/lush.nvim"}) +vim.pack.add({"https://github.com/savq/melange-nvim" }) + +-- vim.g.melange_enable_font_variants = 0 -- disable font variants +-- require("lush") -- make sure Lush is installed +-- require("melange.build").build() -- Compile to vimscript +vim.cmd.colorscheme("melange") diff --git a/lua/plugins/flash.lua b/lua/plugins/flash.lua new file mode 100644 index 0000000..d80ca5d --- /dev/null +++ b/lua/plugins/flash.lua @@ -0,0 +1,19 @@ +vim.pack.add({ "https://github.com/folke/flash.nvim" }) + +require("flash").setup({ + modes = + { + search = + { + enabled = true + } + } +}) + +vim.keymap.set({ "n", "x", "o" }, "s", function() require("flash").jump() end) +vim.keymap.set({ "n", "x", "o" }, "S", function() require("flash").treesitter() end) +vim.keymap.set({ "o" }, "r", function() require("flash").remote() end) +vim.keymap.set({ "o", "x" }, "R", function() require("flash").treesitter_search() end) +vim.keymap.set({ "c" }, "", function() require("flash").toggle() end) + + diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..5eae876 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,10 @@ +require("plugins.colorscheme") +require("plugins.telescope") +require("plugins.treesitter") +require("plugins.lsp") +require("plugins.oil") +require("plugins.cmp") +require("plugins.multicursor") +require("plugins.lsplines") +require("plugins.mini") +require("plugins.flash") diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..98ff23d --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,41 @@ +vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig' }) +vim.lsp.enable({ 'lua_ls' }) +vim.lsp.enable({ 'clangd' }) + +vim.lsp.config("rust_analyzer", { + settings = { + ["rust-analyzer"] = { + completion = + { + postfix = { enable = false, }, + }, + } + }, +}) +vim.lsp.enable('rust_analyzer', { + settings = { + ['rust-analyzer'] = { + completion = { + postfix = { + enable = true, -- Postfix snippets + }, + }, + check = { + command = "clippy", + }, + }, + }, +}) + +vim.keymap.set("n", "t", vim.diagnostic.open_float) +vim.keymap.set("n", "sr", vim.lsp.buf.rename) +vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) +vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) +vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) +vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) +vim.keymap.set("v", "ca", vim.lsp.buf.code_action, opts) +vim.keymap.set("n", "f", function() + vim.lsp.buf.format({ async = true }) +end, opts) +vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) +vim.lsp.inlay_hint.enable(false, nil) diff --git a/lua/plugins/lsplines.lua b/lua/plugins/lsplines.lua new file mode 100644 index 0000000..f1729eb --- /dev/null +++ b/lua/plugins/lsplines.lua @@ -0,0 +1,4 @@ +vim.pack.add({ "https://git.sr.ht/~whynothugo/lsp_lines.nvim" }) + +require("lsp_lines").setup() +vim.diagnostic.config({ virtual_lines = { only_current_line = true } }) diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua new file mode 100644 index 0000000..d693289 --- /dev/null +++ b/lua/plugins/mini.lua @@ -0,0 +1,6 @@ +vim.pack.add({"https://github.com/nvim-mini/mini.surround"}) +require('mini.surround').setup() + +-- Comments +vim.pack.add({"https://github.com/nvim-mini/mini.comment"}) +require('mini.comment').setup() diff --git a/lua/plugins/multicursor.lua b/lua/plugins/multicursor.lua new file mode 100644 index 0000000..5e2494a --- /dev/null +++ b/lua/plugins/multicursor.lua @@ -0,0 +1,87 @@ +vim.pack.add({ "https://github.com/jake-stewart/multicursor.nvim" }) + +local mc = require("multicursor-nvim") +mc.setup() + +local set = vim.keymap.set + +-- Add or skip cursor above/below the main cursor. +set({ "n", "x" }, "", function() + mc.lineAddCursor(-1) +end) +set({ "n", "x" }, "", function() + mc.lineAddCursor(1) +end) +set({ "n", "x" }, "", function() + mc.lineSkipCursor(-1) +end) +set({ "n", "x" }, "", function() + mc.lineSkipCursor(1) +end) + +-- Add or skip adding a new cursor by matching word/selection +set({ "n", "x" }, "", function() + mc.matchAddCursor(1) +end) +set({ "n", "x" }, "", function() + mc.matchSkipCursor(1) +end) +set({ "n", "x" }, "", function() + mc.matchAddCursor(-1) +end) +set({ "n", "x" }, "", function() + mc.matchSkipCursor(-1) +end) + +-- Add and remove cursors with control + left click. +set("n", "", mc.handleMouse) +set("n", "", mc.handleMouseDrag) +set("n", "", mc.handleMouseRelease) + +-- Disable and enable cursors. +set({ "n", "x" }, "", mc.toggleCursor) + +-- Mappings defined in a keymap layer only apply when there are +-- multiple cursors. This lets you have overlapping mappings. +mc.addKeymapLayer(function(layerSet) + -- Select a different cursor as the main one. + layerSet({ "n", "x" }, "", mc.prevCursor) + layerSet({ "n", "x" }, "", mc.nextCursor) + + -- Delete the main cursor. + layerSet({ "n", "x" }, "x", mc.deleteCursor) + + -- Enable and clear cursors using escape. + layerSet("n", "", function() + if not mc.cursorsEnabled() then + mc.enableCursors() + else + mc.clearCursors() + end + end) +end) + +-- Customize how cursors look. +local hl = vim.api.nvim_set_hl +hl(0, "MultiCursorCursor", { reverse = true, fg = "#aaaaff" }) +hl(0, "MultiCursorVisual", { link = "Visual" }) +hl(0, "MultiCursorSign", { link = "SignColumn" }) +hl(0, "MultiCursorMatchPreview", { link = "Search" }) +hl(0, "MultiCursorDisabledCursor", { reverse = true }) +hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) +hl(0, "MultiCursorDisabledSign", { link = "SignColumn" }) + +-- Autocmds to change main cursor color when multicursors is active +vim.api.nvim_create_autocmd("User", { + pattern = "MultiCursorStart", + callback = function() + vim.api.nvim_set_hl(0, "Cursor", { bg = "#000000", fg = "#ffffff" }) -- bright red + end, +}) + +vim.api.nvim_create_autocmd("User", { + pattern = "MultiCursorExit", + callback = function() + vim.api.nvim_set_hl(0, "Cursor", { link = "Cursor" }) -- restore default + end, +}) diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua new file mode 100644 index 0000000..06b7330 --- /dev/null +++ b/lua/plugins/oil.lua @@ -0,0 +1,18 @@ +vim.pack.add({ + "https://github.com/nvim-mini/mini.icons", + "https://github.com/stevearc/oil.nvim" +}) + +require('mini.icons').setup() +require("oil").setup({ + default_file_explorer = true, + + columns = { + "icon", + }, + skip_confirm_for_simple_edits = true, + constrain_cursor = "editable", +}) + +-- Open oil +vim.keymap.set("n", "pv", vim.cmd.Oil) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..a9a480a --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,36 @@ +local hooks = function(ev) + local name, kind = ev.data.spec.name, ev.data.kind + if name == 'telescope-fzf-native.nvim' and (kind == 'install' or kind == 'update') then + vim.system({ 'make' }, { cwd = ev.data.path }):wait() + end +end +vim.api.nvim_create_autocmd('PackChanged', { callback = hooks }) + +vim.pack.add({ + "https://github.com/nvim-lua/plenary.nvim", + "https://github.com/nvim-lua/telescope.nvim", + "https://github.com/nvim-telescope/telescope-fzf-native.nvim", +}) + +-- Keymaps +local builtin = require("telescope.builtin") +vim.keymap.set("n", "pf", builtin.find_files, {}) +vim.keymap.set("n", "pb", builtin.buffers, {}) +vim.keymap.set("n", "ps", builtin.live_grep, {}) +vim.keymap.set("n", "pd", builtin.diagnostics, {}) + +-- fzf +require("telescope").load_extension("fzf") + +-- telescope setup +require("telescope").setup({ + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + }, +}) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..4fa6eb4 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,81 @@ +vim.api.nvim_create_autocmd('PackChanged', { + callback = function(ev) + local name, kind = ev.data.spec.name, ev.data.kind + if name == 'nvim-treesitter' and kind == 'update' then + if not ev.data.active then vim.cmd.packadd('nvim-treesitter') end + vim.cmd(':TSUpdate') + end + end +}) + +vim.pack.add( + { { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" } } +) + +local ts = require('nvim-treesitter') +ts.setup { + -- Directory to install parsers and queries to (prepended to `runtimepath` to have priority) + install_dir = vim.fn.stdpath('data') .. '/site', + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { enable = false }, +} + +local languages = +{ + "bash", + "c", + "diff", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "rust", + "toml", + "vim", + "vimdoc", + "yaml", + "wgsl", +} + +ts.install(languages):wait(300000) + +for _, lang in pairs(languages) do + vim.api.nvim_create_autocmd('FileType', { + pattern = { lang }, + callback = function() vim.treesitter.start() end, + }) +end + +-- Incremental selection keybindings +vim.keymap.set({ 'x' }, '', function() + require 'vim.treesitter._select'.select_prev(vim.v.count1) +end, { desc = 'Select previous treesitter node' }) + +vim.keymap.set({ 'x' }, '', function() + require 'vim.treesitter._select'.select_next(vim.v.count1) +end, { desc = 'Select next treesitter node' }) + +vim.keymap.set({ 'x', 'o' }, 'v', function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require 'vim.treesitter._select'.select_parent(vim.v.count1) + else + vim.lsp.buf.selection_range(vim.v.count1) + end +end, { desc = 'Select parent treesitter node or outer incremental lsp selections' }) + +vim.keymap.set({ 'x', 'o' }, 'V', function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require 'vim.treesitter._select'.select_child(vim.v.count1) + else + vim.lsp.buf.selection_range(-vim.v.count1) + end +end, { desc = 'Select child treesitter node or inner incremental lsp selections' }) + diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..753c35a --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,73 @@ +{ + "plugins": { + "Comment.nvim": { + "rev": "e30b7f2008e52442154b66f7c519bfd2f1e32acb", + "src": "https://github.com/numToStr/Comment.nvim" + }, + "blink.cmp": { + "rev": "a327b19a419347084074cce77f6cd074f54705ac", + "src": "https://github.com/saghen/blink.cmp" + }, + "colorful-menu.nvim": { + "rev": "b51a659459df8d078201aefc995db8175ed55e84", + "src": "https://github.com/xzbdmw/colorful-menu.nvim" + }, + "flash.nvim": { + "rev": "fcea7ff883235d9024dc41e638f164a450c14ca2", + "src": "https://github.com/folke/flash.nvim" + }, + "lsp_lines.nvim": { + "rev": "a92c755f182b89ea91bd8a6a2227208026f27b4d", + "src": "https://git.sr.ht/~whynothugo/lsp_lines.nvim" + }, + "lush.nvim": { + "rev": "9c60ec2279d62487d942ce095e49006af28eed6e", + "src": "https://github.com/rktjmp/lush.nvim" + }, + "melange-nvim": { + "rev": "ce42f6b629beeaa00591ba73a77d3eeac4cf28ce", + "src": "https://github.com/savq/melange-nvim" + }, + "mini.comment": { + "rev": "8e5ff3ed3cc0e8f216617aae01020c00c20f7a87", + "src": "https://github.com/nvim-mini/mini.comment" + }, + "mini.icons": { + "rev": "7fdae2443a0e2910015ca39ad74b50524ee682d3", + "src": "https://github.com/nvim-mini/mini.icons" + }, + "mini.surround": { + "rev": "2715e04bea3ec9244f15b421dc5b18c0fe326210", + "src": "https://github.com/nvim-mini/mini.surround" + }, + "multicursor.nvim": { + "rev": "704b99f10a72cc05d370cfeb294ff83412a8ab55", + "src": "https://github.com/jake-stewart/multicursor.nvim" + }, + "nvim-lspconfig": { + "rev": "bedca8b426b2fee0ccac596d167d71bbe971253f", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "4916d6592ede8c07973490d9322f187e07dfefac", + "src": "https://github.com/nvim-treesitter/nvim-treesitter", + "version": "'main'" + }, + "oil.nvim": { + "rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e", + "src": "https://github.com/stevearc/oil.nvim" + }, + "plenary.nvim": { + "rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "telescope-fzf-native.nvim": { + "rev": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c", + "src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + "telescope.nvim": { + "rev": "7ef4d6dccb78ee71e552bbd866176762ad328afa", + "src": "https://github.com/nvim-lua/telescope.nvim" + } + } +}