From e4bca2cc5def649619d3c373f797f5ed3ada6a0f Mon Sep 17 00:00:00 2001 From: Albin Chaboissier Date: Fri, 19 Sep 2025 19:57:27 +0200 Subject: [PATCH] initial --- .gitignore | 1 + init.lua | 20 +++++++++ lua/config/config.lua | 3 ++ lua/config/gui.lua | 15 +++++++ lua/config/remaps.lua | 21 +++++++++ lua/config/set.lua | 30 +++++++++++++ lua/plugins/cmp.lua | 60 +++++++++++++++++++++++++ lua/plugins/colors.lua | 34 ++++++++++++++ lua/plugins/formatting.lua | 23 ++++++++++ lua/plugins/harpoon.lua | 30 +++++++++++++ lua/plugins/html.lua | 22 +++++++++ lua/plugins/lsp.lua | 92 ++++++++++++++++++++++++++++++++++++++ lua/plugins/lsp_lines.lua | 7 +++ lua/plugins/ltex.lua | 11 +++++ lua/plugins/metals.lua | 1 + lua/plugins/noconf.lua | 3 ++ lua/plugins/r.lua | 47 +++++++++++++++++++ lua/plugins/rust.lua | 48 ++++++++++++++++++++ lua/plugins/telescope.lua | 12 +++++ 19 files changed, 480 insertions(+) create mode 100644 .gitignore create mode 100644 init.lua create mode 100644 lua/config/config.lua create mode 100644 lua/config/gui.lua create mode 100644 lua/config/remaps.lua create mode 100644 lua/config/set.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/colors.lua create mode 100644 lua/plugins/formatting.lua create mode 100644 lua/plugins/harpoon.lua create mode 100644 lua/plugins/html.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lsp_lines.lua create mode 100644 lua/plugins/ltex.lua create mode 100644 lua/plugins/metals.lua create mode 100644 lua/plugins/noconf.lua create mode 100644 lua/plugins/r.lua create mode 100644 lua/plugins/rust.lua create mode 100644 lua/plugins/telescope.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..599cf61 --- /dev/null +++ b/init.lua @@ -0,0 +1,20 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- load plugins +require("config.config") +require("lazy").setup("plugins") diff --git a/lua/config/config.lua b/lua/config/config.lua new file mode 100644 index 0000000..0292375 --- /dev/null +++ b/lua/config/config.lua @@ -0,0 +1,3 @@ +require("config.set") +require("config.remaps") +require("config.gui") diff --git a/lua/config/gui.lua b/lua/config/gui.lua new file mode 100644 index 0000000..f725a0e --- /dev/null +++ b/lua/config/gui.lua @@ -0,0 +1,15 @@ +local alpha = function() + return string.format("%x", math.floor(255 * vim.g.transparency or 0.8)) +end + +if vim.g.neovide then + vim.o.guifont = "Envy Code R:h18" -- text below applies for VimScript + vim.g.transparency = 0 + vim.g.neovide_transparency = 1 + vim.g.neovide_background_color = "#0f1117" .. alpha() + vim.g.neovide_scale_factor = 1.0 + vim.g.neovide_window_blurred = true + vim.g.neovide_cursor_animation_length = 0.08 + vim.g.neovide_cursor_trail_size = 0.5 + vim.g.neovide_scroll_animation_length = 0.1 +end diff --git a/lua/config/remaps.lua b/lua/config/remaps.lua new file mode 100644 index 0000000..6a4fef5 --- /dev/null +++ b/lua/config/remaps.lua @@ -0,0 +1,21 @@ +local map = vim.api.nvim_set_keymap + +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + + +-- 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") + +-- ? +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") diff --git a/lua/config/set.lua b/lua/config/set.lua new file mode 100644 index 0000000..067dadf --- /dev/null +++ b/lua/config/set.lua @@ -0,0 +1,30 @@ +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.cmd("highlight Normal ctermbg=NONE") +vim.cmd("highlight NonText ctermbg=NONE") diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..25b0dec --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,60 @@ +return { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-buffer", + "onsails/lspkind.nvim", -- Pictograms + }, + config = function() + local cmp = require("cmp") + vim.cmd("highlight FloatBorder guibg=NONE") + cmp.setup({ + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = function() + if cmp.visible_docs() then + cmp.close_docs() + else + cmp.open_docs() + end + end, + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "path" }, + { name = "buffer" }, + }), + formatting = { + format = require("lspkind").cmp_format({ + mode = "symbol_text", + maxwidth = { + -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- can also be a function to dynamically calculate max width such as + -- menu = function() return math.floor(0.45 * vim.o.columns) end, + menu = 50, -- leading text (labelDetails) + abbr = 50, -- actual suggestion item + }, + }), + }, + }) + end, +} diff --git a/lua/plugins/colors.lua b/lua/plugins/colors.lua new file mode 100644 index 0000000..16b6e5d --- /dev/null +++ b/lua/plugins/colors.lua @@ -0,0 +1,34 @@ +return { + { + "ellisonleao/gruvbox.nvim", + priority = 1000, + config = function() + -- Default options: + require("gruvbox").setup({ + terminal_colors = true, -- add neovim terminal colors + undercurl = true, + underline = true, + bold = true, + italic = { + strings = true, + emphasis = true, + comments = true, + operators = false, + folds = true, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "hard", -- can be "hard", "soft" or empty string + palette_overrides = {}, + overrides = {}, + dim_inactive = false, + transparent_mode = false, + }) + vim.cmd("colorscheme gruvbox") + end, + }, +} diff --git a/lua/plugins/formatting.lua b/lua/plugins/formatting.lua new file mode 100644 index 0000000..1667ed4 --- /dev/null +++ b/lua/plugins/formatting.lua @@ -0,0 +1,23 @@ +return { + "stevearc/conform.nvim", + opts = {}, + config = function() + local conform = require("conform") + conform.setup({ + scala = { "scalafmt" }, + formatters_by_ft = { + lua = { "stylua" }, + rust = { + "rustfmt", + }, + }, + format_on_save = { + timeout_ms = 500, + }, + }) + + conform.formatters.rustfmt = { + prepend_args = { "--config-path", "/home/albin/coding-projects/rustfmt.toml" }, + } + end, +} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 0000000..71a7106 --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,30 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local harpoon = require("harpoon") + + harpoon:setup() + + vim.keymap.set("n", "a", function() + harpoon:list():add() + end) + vim.keymap.set("n", "e", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + vim.keymap.set("n", "", function() + harpoon:list():select(1) + end) + vim.keymap.set("n", "", function() + harpoon:list():select(2) + end) + vim.keymap.set("n", "", function() + harpoon:list():select(3) + end) + vim.keymap.set("n", "", function() + harpoon:list():select(4) + end) + end, +} diff --git a/lua/plugins/html.lua b/lua/plugins/html.lua new file mode 100644 index 0000000..b37c07c --- /dev/null +++ b/lua/plugins/html.lua @@ -0,0 +1,22 @@ +-- For automatically closing html tags when typed +return { + "windwp/nvim-ts-autotag", + config = function() + require("nvim-ts-autotag").setup({ + opts = { + -- Defaults + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false, -- Auto close on trailing 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", "f", function() + vim.lsp.buf.format({ async = true }) + end, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + end, + }) + end, + }, +} diff --git a/lua/plugins/lsp_lines.lua b/lua/plugins/lsp_lines.lua new file mode 100644 index 0000000..39baafc --- /dev/null +++ b/lua/plugins/lsp_lines.lua @@ -0,0 +1,7 @@ +return { + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + vim.diagnostic.config({ virtual_lines = { only_current_line = true } }) + end, +} diff --git a/lua/plugins/ltex.lua b/lua/plugins/ltex.lua new file mode 100644 index 0000000..4f0701b --- /dev/null +++ b/lua/plugins/ltex.lua @@ -0,0 +1,11 @@ +return { + { + "lervag/vimtex", + lazy = false, -- we don't want to lazy load VimTeX + -- tag = "v2.15", -- uncomment to pin to a specific release + init = function() + -- VimTeX configuration goes here, e.g. + vim.g.vimtex_view_method = "zathura" + end + } +} diff --git a/lua/plugins/metals.lua b/lua/plugins/metals.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/plugins/metals.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/plugins/noconf.lua b/lua/plugins/noconf.lua new file mode 100644 index 0000000..2097c95 --- /dev/null +++ b/lua/plugins/noconf.lua @@ -0,0 +1,3 @@ +return { + "nvim-treesitter/nvim-treesitter" +} diff --git a/lua/plugins/r.lua b/lua/plugins/r.lua new file mode 100644 index 0000000..324777a --- /dev/null +++ b/lua/plugins/r.lua @@ -0,0 +1,47 @@ +return { + "R-nvim/R.nvim", + -- Only required if you also set defaults.lazy = true + lazy = false, + -- R.nvim is still young and we may make some breaking changes from time + -- to time (but also bug fixes all the time). If configuration stability + -- is a high priority for you, pin to the latest minor version, but unpin + -- it and try the latest version before reporting an issue: + -- version = "~0.1.0" + config = function() + -- Create a table with the options to be passed to setup() + ---@type RConfigUserOpts + local opts = { + hook = { + on_filetype = function() + vim.api.nvim_buf_set_keymap(0, "n", "", "RDSendLine", {}) + vim.api.nvim_buf_set_keymap(0, "v", "", "RSendSelection", {}) + end, + }, + R_args = { "--quiet", "--no-save" }, + min_editor_width = 72, + rconsole_width = 78, + objbr_mappings = { -- Object browser keymap + c = "class", -- Call R functions + ["gg"] = "head({object}, n = 15)", -- Use {object} notation to write arbitrary R code. + v = function() + -- Run lua functions + require("r.browser").toggle_view() + end, + }, + disable_cmds = { + "RClearConsole", + "RCustomStart", + "RSPlot", + "RSaveClose", + }, + } + -- Check if the environment variable "R_AUTO_START" exists. + -- If using fish shell, you could put in your config.fish: + -- alias r "R_AUTO_START=true nvim" + -- if vim.env.R_AUTO_START == "true" then + opts.auto_start = "on startup" + opts.objbr_auto_start = true + -- end + require("r").setup(opts) + end, +} diff --git a/lua/plugins/rust.lua b/lua/plugins/rust.lua new file mode 100644 index 0000000..16d6326 --- /dev/null +++ b/lua/plugins/rust.lua @@ -0,0 +1,48 @@ +return { + "mrcjkb/rustaceanvim", + version = "^5", -- Recommended + lazy = false, -- This plugin is already lazy + config = function() + vim.g.rustaceanvim = { + -- Plugin configuration + tools = {}, + -- LSP configuration + server = { + capabilities = { + textDocument = { + completion = { + completionItem = { + snippetSupport = false, + }, + }, + }, + }, + on_attach = function(client, bufnr) + -- you can also put keymaps in here + vim.keymap.set("n", "ca", function() + vim.cmd.RustLsp("codeAction") -- supports rust-analyzer's grouping + -- or vim.lsp.buf.codeAction() if you don't want grouping. + end, { silent = true, buffer = bufnr }) + vim.keymap.set( + "n", + "t", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions + function() + vim.cmd.RustLsp({ "renderDiagnostic", "current" }) -- defaults to 'cycle' + end, + { silent = true, buffer = bufnr } + ) + end, + default_settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + check = { + command = "clippy", + }, + }, + }, + }, + -- DAP configuration + dap = {}, + } + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..05db236 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,12 @@ +return { + { + "nvim-telescope/telescope.nvim", + tag = "0.1.6", + dependencies = { "nvim-lua/plenary.nvim" }, + init = function () + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'pf', builtin.find_files, {}) + end + }, +} +