From d2e8cd40f1f89e85ea6c546e40076553b36539c1 Mon Sep 17 00:00:00 2001 From: THEON-1 Date: Fri, 10 Oct 2025 12:19:28 +0200 Subject: [PATCH] initial commit --- .envrc | 12 ++++++ .luarc.json | 15 +++++++ init.lua | 1 + lazy-lock.json | 22 ++++++++++ lua/config/init.lua | 4 ++ lua/config/keybinds.lua | 75 ++++++++++++++++++++++++++++++++++ lua/config/lazy.lua | 35 ++++++++++++++++ lua/config/vars.lua | 40 ++++++++++++++++++ lua/plugins/blink.lua | 48 ++++++++++++++++++++++ lua/plugins/fugitive.lua | 7 ++++ lua/plugins/gruvbox.lua | 17 ++++++++ lua/plugins/harpoon.lua | 38 +++++++++++++++++ lua/plugins/image.lua | 16 ++++++++ lua/plugins/markdown.lua | 10 +++++ lua/plugins/mason.lua | 23 +++++++++++ lua/plugins/molten.lua | 11 +++++ lua/plugins/noice.lua | 25 ++++++++++++ lua/plugins/notify.lua | 4 ++ lua/plugins/nvim-lspconfig.lua | 7 ++++ lua/plugins/oil.lua | 49 ++++++++++++++++++++++ lua/plugins/telescope.lua | 26 ++++++++++++ lua/plugins/treesitter.lua | 7 ++++ lua/plugins/undotree.lua | 7 ++++ 23 files changed, 499 insertions(+) create mode 100644 .envrc create mode 100644 .luarc.json create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/config/init.lua create mode 100644 lua/config/keybinds.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/vars.lua create mode 100644 lua/plugins/blink.lua create mode 100644 lua/plugins/fugitive.lua create mode 100644 lua/plugins/gruvbox.lua create mode 100644 lua/plugins/harpoon.lua create mode 100644 lua/plugins/image.lua create mode 100644 lua/plugins/markdown.lua create mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/molten.lua create mode 100644 lua/plugins/noice.lua create mode 100644 lua/plugins/notify.lua create mode 100644 lua/plugins/nvim-lspconfig.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 lua/plugins/undotree.lua diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..dcc32cc --- /dev/null +++ b/.envrc @@ -0,0 +1,12 @@ +export MAMBA_EXE='/home/maxime/.local/bin/micromamba'; +export MAMBA_ROOT_PREFIX='/home/maxime/.micromamba'; +__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)" +if [ $? -eq 0 ]; then + eval "$__mamba_setup" +else + alias micromamba="$MAMBA_EXE" # Fallback on help from micromamba activate +fi +unset __mamba_setup + +micromamba activate nvim + diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..3d0b956 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,15 @@ +{ + "runtime.version": "LuaJIT", + "runtime.path": [ + "lua/?.lua", + "lua/?/init.lua" + ], + "diagnostics.globals": ["vim"], + "workspace.checkThirdParty": false, + "workspace.library": [ + "$VIMRUNTIME", + "$XDG_DATA_HOME/nvim/lazy", + "${3rd}/luv/library" + ] +} + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..dbc863e --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("config") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..97670bb --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,22 @@ +{ + "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, + "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, + "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, + "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, + "lazy.nvim": { "branch": "main", "commit": "4ded3ff73bf42e1c657e5deb85d8bbd887d0172e" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "6bdb14f230de0904229ec367b410fb817e59b072" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "mini.nvim": { "branch": "main", "commit": "ef89bb115244297ed440441faa61759ddcf4a970" }, + "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, + "noice.nvim": { "branch": "main", "commit": "38c702be0d8fea81527ee6a73e1e834e72481193" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" }, + "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, + "nvim-treesitter": { "branch": "main", "commit": "3ab4f2d2d20be55874e2eb575145c6928d7d7d0e" }, + "oil.nvim": { "branch": "master", "commit": "919e155fdf38e9148cdb5304faaaf53c20d703ea" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "d53856423be5ef3c267d26ee261b0981b372f718" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" }, + "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" } +} diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..bd4094e --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,4 @@ +require("config.vars") +require("config.keybinds") + +require("config.lazy") diff --git a/lua/config/keybinds.lua b/lua/config/keybinds.lua new file mode 100644 index 0000000..b609587 --- /dev/null +++ b/lua/config/keybinds.lua @@ -0,0 +1,75 @@ +-- move selection in visual mode +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- yank to clipboard +vim.keymap.set("n", "y", "\"+y") +vim.keymap.set("v", "y", "\"+y") +vim.keymap.set("n", "Y", "\"+Y") + +-- paste without copy +vim.keymap.set("x", "p", "\"_dP") + +-- delete without copy +vim.keymap.set("n", "d", "\"_d"); +vim.keymap.set("v", "d", "\"_d"); + +-- search and replace hovered word +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) + +-- make file executable +vim.keymap.set("n", "x", "!chmod +x %", {silent = true}) + +-- insert shebang on top of file +vim.keymap.set("n", "sb", function () + local filetype = vim.bo.filetype + local mapping = { + jl = "julia", + julia = "julia", + sh = "bash", + zsh = "zsh", + py = "/usr/bin/env python3", + python = "/usr/bin/env python3", + } + local command = mapping[filetype] + if (command == nil) then return end + -- local handle = assert(io.popen(string.format("/bin/zsh -c \"where %s\"", command))) + -- local result = (handle:lines())() + -- handle:close() + local buf = vim.api.nvim_get_current_buf() + -- print(result) + vim.api.nvim_buf_set_lines(buf, 0, 0, true, { "#!" .. command }) + vim.api.nvim_command('write') + local filename = vim.api.nvim_buf_get_name(0) + assert(io.popen(string.format("/usr/bin/chmod +x \"%s\"", filename))) +end) + +-- window switching +vim.keymap.set("n", "", "wincmd h") +vim.keymap.set("n", "", "wincmd j") +vim.keymap.set("n", "", "wincmd k") +vim.keymap.set("n", "", "wincmd l") + +-- window movement +vim.keymap.set("n", "", "wincmd H") +vim.keymap.set("n", "", "wincmd L") +vim.keymap.set("n", "", "wincmd K") +vim.keymap.set("n", "", "wincmd J") +vim.keymap.set("n", "", "wincmd r") + +-- lsp +vim.keymap.set("n", "", vim.lsp.buf.code_action) +vim.keymap.set("n", "", vim.lsp.buf.format) +vim.keymap.set("n", "gD", vim.lsp.buf.declaration) +vim.keymap.set("n", "gd", vim.lsp.buf.definition) +vim.keymap.set("n", "gt", vim.lsp.buf.type_definition) +vim.keymap.set("n", "K", vim.lsp.buf.hover) +vim.keymap.set("n", "ls", vim.lsp.buf.document_symbol) +vim.keymap.set("n", "li", vim.lsp.buf.implementation) +vim.keymap.set("n", "lr", vim.lsp.buf.references) +vim.keymap.set("n", "", vim.lsp.buf.rename) +vim.keymap.set("n", "sh", vim.lsp.buf.signature_help) +vim.keymap.set("n", "do", vim.diagnostic.open_float) +vim.keymap.set("n", "dn", function() vim.diagnostic.jump({count=1, float=true}) end) +vim.keymap.set("n", "dp", function() vim.diagnostic.jump({count=-1, float=true}) end) + diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- 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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/config/vars.lua b/lua/config/vars.lua new file mode 100644 index 0000000..c277012 --- /dev/null +++ b/lua/config/vars.lua @@ -0,0 +1,40 @@ + +vim.opt.nu = true +vim.opt.relativenumber = false + +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") .. "/.local/share/nvim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = true +vim.opt.incsearch = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.conceallevel = 1 + +vim.g.mapleader = " " +vim.g.maplocalleader = "," + +-- set python path +vim.g.python3_host_prog = os.getenv("HOME") .. "/.micromamba/envs/nvim/bin/python" + +-- disable mouse +vim.opt.mouse = "" + +vim.opt.termguicolors = true + diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua new file mode 100644 index 0000000..6ca7703 --- /dev/null +++ b/lua/plugins/blink.lua @@ -0,0 +1,48 @@ +return { + "saghen/blink.cmp", + version = '1.*', + + ---@module 'blink.cmp' + ---@type blink.cmp.config + opts = { + keymap = { + preset = 'default', + + [''] = { 'select_prev', 'fallback' }, + [''] = { 'select_next', 'fallback' }, + [''] = { 'select_prev' }, + [''] = { 'select_next' }, + [''] = { 'accept' }, + [''] = { 'cancel' }, + [''] = { 'scroll_documentation_up' }, + [''] = { 'scroll_documentation_down' }, + }, + + appearance = { + nerd_font_variant = 'mono', + }, + + completion = { + documentation = { + auto_show = true, + }, + }, + + sources = { + default = { + 'lsp', + 'path', + 'buffer', + }, + }, + + fuzzy = { + implementation = "prefer_rust_with_warning", + }, + }, + + opts_extend = { + "sources.default", + }, +} + diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua new file mode 100644 index 0000000..e5c4585 --- /dev/null +++ b/lua/plugins/fugitive.lua @@ -0,0 +1,7 @@ +return { + 'tpope/vim-fugitive', + cmd = { + "G", + }, +} + diff --git a/lua/plugins/gruvbox.lua b/lua/plugins/gruvbox.lua new file mode 100644 index 0000000..f7d8ef9 --- /dev/null +++ b/lua/plugins/gruvbox.lua @@ -0,0 +1,17 @@ +return { + "ellisonleao/gruvbox.nvim", + priority = 1000, + config = function() + vim.cmd([[colorscheme gruvbox]]) + end, + opts = { + italic = { + strings = false, + emphasis = true, + comments = true, + operators = false, + folds = true, + }, + }, +} + diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 0000000..b84a08e --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,38 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + requires = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-telescope/telescope.nvim' }, + }, + keys = { + { "a", function() require("harpoon"):list():add() end }, + { "", function() + local harpoon = require("harpoon") + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ results = file_paths }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() + end + toggle_telescope(harpoon:list()) + end, desc = "Open harpoon window" }, + + { "", function() require("harpoon"):list():select(1) end }, + { "", function() require("harpoon"):list():select(2) end }, + { "", function() require("harpoon"):list():select(3) end }, + { "", function() require("harpoon"):list():select(4) end }, + + { "", function() require("harpoon"):list():prev() end }, + { "", function() require("harpoon"):list():next() end }, + }, +} + diff --git a/lua/plugins/image.lua b/lua/plugins/image.lua new file mode 100644 index 0000000..513b6b0 --- /dev/null +++ b/lua/plugins/image.lua @@ -0,0 +1,16 @@ +return { + '3rd/image.nvim', + build = false, + opts = { + processor = 'magick_cli', + backend = 'kitty', + integrations = { markdown = { enabled = true, }, }, + max_width = 100, + max_height = 12, + max_height_window_percentage = math.huge, + max_width_window_percentage = math.huge, + window_overlap_clear_enabled = true, + window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '', }, + }, +} + diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua new file mode 100644 index 0000000..b7b78d4 --- /dev/null +++ b/lua/plugins/markdown.lua @@ -0,0 +1,10 @@ +return { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-mini/mini.nvim', + }, + ---@module 'render-markdown' + ---@type render.md.UserConfig +} + diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..8a5828b --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,23 @@ +return { + "mason-org/mason-lspconfig.nvim", + opts = { + automatic_enable = true, + }, + dependencies = { + { + "mason-org/mason.nvim", + opts = { + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }, + lazy = false, + }, + "neovim/nvim-lspconfig", + }, +} + diff --git a/lua/plugins/molten.lua b/lua/plugins/molten.lua new file mode 100644 index 0000000..24b9587 --- /dev/null +++ b/lua/plugins/molten.lua @@ -0,0 +1,11 @@ +return { + 'benlubas/molten-nvim', + version = '^1.1.0', + depencies = { '3rd/image.nvim', }, + build = ':UpdateRemotePlugins', + init = function() + vim.g.molten_image_provider = 'image.nvim' + vim.g.molten_output_win_max_height = 20 + end, +} + diff --git a/lua/plugins/noice.lua b/lua/plugins/noice.lua new file mode 100644 index 0000000..f36e6ca --- /dev/null +++ b/lua/plugins/noice.lua @@ -0,0 +1,25 @@ +return { + 'folke/noice.nvim', + event = 'VeryLazy', + dependencies = { + 'MunifTanjim/nui.nvim', + 'rcarriga/nvim-notify', + }, + opts = { + lsp = { + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, + }, + }, + presets = { + bottom_search = true, + command_palette = true, + long_message_to_split = true, + inc_rename = true, + lsp_doc_border = true, + }, + }, +} + diff --git a/lua/plugins/notify.lua b/lua/plugins/notify.lua new file mode 100644 index 0000000..e53ef26 --- /dev/null +++ b/lua/plugins/notify.lua @@ -0,0 +1,4 @@ +return { + 'rcarriga/nvim-notify', +} + diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua new file mode 100644 index 0000000..a1042bc --- /dev/null +++ b/lua/plugins/nvim-lspconfig.lua @@ -0,0 +1,7 @@ +return { + "neovim/nvim-lspconfig", + cmd = { 'LspInfo', 'LspInstall', 'LspStart' }, + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { 'saghen/blink.cmp' }, +} + diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua new file mode 100644 index 0000000..5fd7bc8 --- /dev/null +++ b/lua/plugins/oil.lua @@ -0,0 +1,49 @@ +return { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = { + columns = { + "icon", + "permissions", + }, + default_file_explorer = true, + view_options = { + show_hidden = true, + }, + win_options = { + wrap = false, + signcolumn = "yes", + cursorcolumn = false, + foldcolumn = "0", + spell = false, + list = false, + conceallevel = 3, + concealcursor = "nvic", + }, + delete_to_trash = false, + skip_confirm_for_simple_edits = false, + prompt_save_for_select_new_entry = true, + lsp_file_methods = { + enabled = true, + timeout_ms = 1000, + autosave_changes = false, + }, + constrain_cursor = "editable", + watch_for_changes = false, + keymaps = { + ["g"] = { "actions.show_help", mode = "n" }, + [""] = "actions.select", + [""] = "actions.preview", + ["-"] = { "actions.open_cwd", mode = "n" }, + ["+"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" }, + ["_"] = "actions.parent", + ["*"] = "actions.open_terminal", + }, + }, + keys = { + { "_", function() require("oil").open() end, desc = "open files" }, + }, + lazy = false, +} + diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..f9b5a20 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,26 @@ +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + requires = { + { 'nvim-lua/plenary.nvim' }, + }, + config = function() + require('telescope').load_extension("notify") + end, + keys = { + { "ff", "Telescope find_files", mode = "n" }, + { "g", "Telescope live_grep", mode = "n" }, + { "", "Telescope git_files", mode = "n" }, + }, + cmd = { + 'Telescope', + }, + opts = { + defaults = { + preview = { + treesitter = false, + }, + }, + }, +} + diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..d01af4c --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,7 @@ +return { + 'nvim-treesitter/nvim-treesitter', + lazy = false, + branch = 'main', + build = ':TSUpdate', +} + diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 0000000..d2db37a --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1,7 @@ +return { + 'mbbill/undotree', + keys = { + { "u", vim.cmd.UndotreeToggle, mode = "n", desc = "Open Undotree" }, + }, +} +