diff options
| author | Tom Li Dobnik <tomlidobnik1@gmail.com> | 2025-08-09 17:12:43 +0200 |
|---|---|---|
| committer | Tom Li Dobnik <tomlidobnik1@gmail.com> | 2025-08-09 17:12:43 +0200 |
| commit | ea82cbb1c0b778dd946c717cceace53fab391ba8 (patch) | |
| tree | f0c84a86f48d61d918b6de9dc464c08370ab6a7c /.config/nvim | |
init
Diffstat (limited to '.config/nvim')
40 files changed, 1733 insertions, 0 deletions
diff --git a/.config/nvim/.editorconfig b/.config/nvim/.editorconfig new file mode 100644 index 0000000..9a6cc75 --- /dev/null +++ b/.config/nvim/.editorconfig @@ -0,0 +1,3 @@ +[*.lua] +indent_style = space +indent_size = 2 diff --git a/.config/nvim/.luarc.json b/.config/nvim/.luarc.json new file mode 100644 index 0000000..59e3c38 --- /dev/null +++ b/.config/nvim/.luarc.json @@ -0,0 +1,10 @@ +{ + "diagnostics.globals": [ + "MiniFiles", + "Snacks", + "MiniSplitjoin", + "hipatterns", + "MiniDiff", + "vim" + ] +}
\ No newline at end of file diff --git a/.config/nvim/after/ftplugin/css.lua b/.config/nvim/after/ftplugin/css.lua new file mode 100644 index 0000000..5b3770c --- /dev/null +++ b/.config/nvim/after/ftplugin/css.lua @@ -0,0 +1,3 @@ +local set = vim.opt_local + +set.shiftwidth = 2 diff --git a/.config/nvim/after/ftplugin/html.lua b/.config/nvim/after/ftplugin/html.lua new file mode 100644 index 0000000..5b3770c --- /dev/null +++ b/.config/nvim/after/ftplugin/html.lua @@ -0,0 +1,3 @@ +local set = vim.opt_local + +set.shiftwidth = 2 diff --git a/.config/nvim/after/ftplugin/htmldjango.lua b/.config/nvim/after/ftplugin/htmldjango.lua new file mode 100644 index 0000000..2a12368 --- /dev/null +++ b/.config/nvim/after/ftplugin/htmldjango.lua @@ -0,0 +1,15 @@ +local set = vim.opt_local + +-- set.shiftwidth = 2 + +vim.api.nvim_create_augroup("DjangoTemplates", { clear = true }) + +vim.api.nvim_create_autocmd("FileType", { + group = "DjangoTemplates", + pattern = "htmldjango", + callback = function() + vim.cmd("setlocal syntax=on") + vim.cmd("syntax include @Javascript syntax/javascript.vim") + vim.cmd("syntax region javascript start=/<script>/ end=/<\\/script>/ contains=@Javascript") + end, +}) diff --git a/.config/nvim/after/ftplugin/javascript.lua b/.config/nvim/after/ftplugin/javascript.lua new file mode 100644 index 0000000..5b3770c --- /dev/null +++ b/.config/nvim/after/ftplugin/javascript.lua @@ -0,0 +1,3 @@ +local set = vim.opt_local + +set.shiftwidth = 2 diff --git a/.config/nvim/after/ftplugin/javascriptreact.lua b/.config/nvim/after/ftplugin/javascriptreact.lua new file mode 100644 index 0000000..5b3770c --- /dev/null +++ b/.config/nvim/after/ftplugin/javascriptreact.lua @@ -0,0 +1,3 @@ +local set = vim.opt_local + +set.shiftwidth = 2 diff --git a/.config/nvim/after/ftplugin/json.lua b/.config/nvim/after/ftplugin/json.lua new file mode 100644 index 0000000..a38fed5 --- /dev/null +++ b/.config/nvim/after/ftplugin/json.lua @@ -0,0 +1,3 @@ +local set = vim.opt_local + +set.conceallevel = 0 diff --git a/.config/nvim/after/ftplugin/lua.lua b/.config/nvim/after/ftplugin/lua.lua new file mode 100644 index 0000000..c0e2391 --- /dev/null +++ b/.config/nvim/after/ftplugin/lua.lua @@ -0,0 +1,5 @@ +local set = vim.opt_local + +set.shiftwidth = 2 +set.number = true +set.relativenumber = true diff --git a/.config/nvim/after/ftplugin/md.lua b/.config/nvim/after/ftplugin/md.lua new file mode 100644 index 0000000..5b3770c --- /dev/null +++ b/.config/nvim/after/ftplugin/md.lua @@ -0,0 +1,3 @@ +local set = vim.opt_local + +set.shiftwidth = 2 diff --git a/.config/nvim/after/ftplugin/rust.lua b/.config/nvim/after/ftplugin/rust.lua new file mode 100644 index 0000000..4060c9d --- /dev/null +++ b/.config/nvim/after/ftplugin/rust.lua @@ -0,0 +1,13 @@ +local bufnr = vim.api.nvim_get_current_buf() +vim.keymap.set("n", "<leader>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", + "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions + function() + vim.cmd.RustLsp({ "hover", "actions" }) + end, + { silent = true, buffer = bufnr } +) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..75ae3e9 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,5 @@ +vim.g.bullets_enable_in_empty_buffers = 0 +require("config.lazy") +require("options") +require("mappings") +require("autocmds") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..369d7ab --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,44 @@ +{ + "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, + "blink-emoji.nvim": { "branch": "master", "commit": "f22ce8cac02a6ece05368220f1e38bd34fe376f9" }, + "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" }, + "blink.compat": { "branch": "main", "commit": "2ed6d9a28b07fa6f3bface818470605f8896408c" }, + "bullets.vim": { "branch": "master", "commit": "1c13e510e11d08b0259e8e627f128359c5521962" }, + "cmp-sql": { "branch": "master", "commit": "54193ac99e3855c6ffaa36f83a7c50213df03157" }, + "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, + "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "fzf-lua": { "branch": "main", "commit": "8c8845ca6d05bc768b7ce27ebe3682ddf7e6a996" }, + "gitsigns.nvim": { "branch": "main", "commit": "8bdaccdb897945a3c99c1ad8df94db0ddf5c8790" }, + "hardtime.nvim": { "branch": "main", "commit": "145b930954a3146cfb5b8a73cdcad42eb7d2740c" }, + "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "60eaff7a470b8e78ddff09d847d17a011f560759" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" }, + "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, + "mini.nvim": { "branch": "main", "commit": "de0a88d925c8e69fdbb498141207ee43504e5cd1" }, + "nord.nvim": { "branch": "master", "commit": "80c1e5321505aeb22b7a9f23eb82f1e193c12470" }, + "nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, + "nvim-lspconfig": { "branch": "master", "commit": "03bc581e05e81d33808b42b2d7e76d70adb3b595" }, + "nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, + "oil.nvim": { "branch": "master", "commit": "685cdb4ffa74473d75a1b97451f8654ceeab0f4a" }, + "outline.nvim": { "branch": "main", "commit": "321f89ef79f168a78685f70d70c52d0e7b563abb" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, + "render-markdown.nvim": { "branch": "main", "commit": "d69f0d8c80ba293d25dad498ec86e9b583a6bbbf" }, + "rustaceanvim": { "branch": "master", "commit": "5120207f90846704a74cbf043295698b009bd5de" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "typst-preview.nvim": { "branch": "master", "commit": "dea4525d5420b7c32eebda7de15a6beb9d6574fa" }, + "undotree": { "branch": "master", "commit": "b951b87b46c34356d44aa71886aecf9dd7f5788a" }, + "vim-tmux-navigator": { "branch": "master", "commit": "96da8e10ce83b754f442c3e25d1bf74451d220f2" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua new file mode 100644 index 0000000..13f235c --- /dev/null +++ b/.config/nvim/lua/autocmds.lua @@ -0,0 +1,28 @@ +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "gitcommit", "markdown" }, + callback = function(event) + vim.keymap.set("i", "`", "`", { buffer = event.buf }) + end, +}) + +vim.api.nvim_create_autocmd("InsertEnter", { + pattern = "*.md", + callback = function() + vim.opt.conceallevel = 0 + end, +}) + +vim.api.nvim_create_autocmd("InsertLeave", { + pattern = "*.md", + callback = function() + vim.opt.conceallevel = 3 + end, +}) diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..ba9b8f3 --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,36 @@ +-- 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 + +-- Hey! Put lazy into the runtimepath for neovim! +vim.opt.runtimepath: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) +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + { import = "config.plugins" }, + }, + ui = { + backdrop = 100, + }, + change_detection = { + -- automatically check for config file changes and reload the ui + enabled = false, + notify = false, -- get a notification when changes are found + }, +}) diff --git a/.config/nvim/lua/config/plugins/blink-cmp.lua b/.config/nvim/lua/config/plugins/blink-cmp.lua new file mode 100644 index 0000000..d51ba4a --- /dev/null +++ b/.config/nvim/lua/config/plugins/blink-cmp.lua @@ -0,0 +1,114 @@ +return { + { + "saghen/blink.compat", + version = "*", + lazy = true, + opts = {}, + }, + { + "saghen/blink.cmp", + event = "VeryLazy", + -- optional: provides snippets for the snippet source + dependencies = { + "rafamadriz/friendly-snippets", + "moyiz/blink-emoji.nvim", + "ray-x/cmp-sql", + }, + + -- use a release tag to download pre-built binaries + version = "1.*", + -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + opts = { + snippets = { + preset = "luasnip", -- Choose LuaSnip as the snippet engine + }, + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { + preset = "default", + }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { + documentation = { auto_show = true, window = { border = "single" } }, + }, + signature = { enabled = true }, + + sources = { + default = { "lsp", "path", "snippets", "buffer", "emoji", "sql" }, + providers = { + snippets = { + name = "snippets", + module = "blink.cmp.sources.snippets", + enabled = true, + min_keyword_length = 2, + score_offset = 80, + }, + emoji = { + module = "blink-emoji", + name = "Emoji", + score_offset = 15, -- Tune by preference + opts = { insert = true }, -- Insert emoji (default) or complete its name + should_show_items = function() + return vim.tbl_contains( + -- Enable emoji completion only for git commits and markdown. + -- By default, enabled for all file-types. + { "gitcommit", "markdown" }, + vim.o.filetype + ) + end, + }, + sql = { + -- IMPORTANT: use the same name as you would for nvim-cmp + name = "sql", + module = "blink.compat.source", + + -- all blink.cmp source config options work as normal: + score_offset = -3, + + -- this table is passed directly to the proxied completion source + -- as the `option` field in nvim-cmp's source config + -- + -- this is NOT the same as the opts in a plugin's lazy.nvim spec + opts = {}, + should_show_items = function() + return vim.tbl_contains( + -- Enable emoji completion only for git commits and markdown. + -- By default, enabled for all file-types. + { "sql" }, + vim.o.filetype + ) + end, + }, + }, + }, + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" }, + }, + opts_extend = { "sources.default" }, + }, +} diff --git a/.config/nvim/lua/config/plugins/colorscheme.lua b/.config/nvim/lua/config/plugins/colorscheme.lua new file mode 100644 index 0000000..ea130c7 --- /dev/null +++ b/.config/nvim/lua/config/plugins/colorscheme.lua @@ -0,0 +1,14 @@ +return { + "shaunsingh/nord.nvim", + priority = 1000, + init = function() + vim.cmd.colorscheme("nord") + vim.cmd.hi("Comment gui=none") + -- Set transparency + vim.cmd("hi Normal guibg=NONE ctermbg=NONE") + vim.cmd("hi NormalFloat guibg=NONE ctermbg=NONE") + vim.cmd("hi SignColumn guibg=NONE") + vim.cmd("hi FloatBorder guibg=NONE") + vim.cmd("hi CursorLine guibg=NONE") + end, +} diff --git a/.config/nvim/lua/config/plugins/conform.lua b/.config/nvim/lua/config/plugins/conform.lua new file mode 100644 index 0000000..afc2dd5 --- /dev/null +++ b/.config/nvim/lua/config/plugins/conform.lua @@ -0,0 +1,33 @@ +return { + "stevearc/conform.nvim", + event = "VeryLazy", + keys = { + { + "<leader>f", + function() + require("conform").format({ async = true, lsp_format = "fallback" }) + end, + mode = "", + desc = "Format buffer", + }, + }, + + opts = { + formatters_by_ft = { + lua = { "stylua" }, + python = { "isort", "black" }, + rust = { "rustfmt" }, + javascript = { "prettierd", "prettier", stop_after_first = true }, + typescript = { "prettierd", "prettier", stop_after_first = true }, + typescriptreact = { "prettierd", "prettier", stop_after_first = true }, + css = { "prettierd", "prettier", stop_after_first = true }, + html = { "prettierd", "prettier", stop_after_first = true }, + htmldjango = { "djlint" }, + typst = { "prettypst" }, + }, + format_on_save = { + timeout_ms = 500, + lsp_format = "fallback", + }, + }, +} diff --git a/.config/nvim/lua/config/plugins/flash.lua b/.config/nvim/lua/config/plugins/flash.lua new file mode 100644 index 0000000..d4de4ee --- /dev/null +++ b/.config/nvim/lua/config/plugins/flash.lua @@ -0,0 +1,17 @@ +return { + "folke/flash.nvim", + event = "VeryLazy", + opts = { + modes = { + search = { enabled = false }, + char = { enabled = false }, + treesitter = { enabled = false }, + remote = { enabled = false }, + }, + }, + -- stylua: ignore + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + }, +} diff --git a/.config/nvim/lua/config/plugins/fzflua.lua b/.config/nvim/lua/config/plugins/fzflua.lua new file mode 100644 index 0000000..ea8a744 --- /dev/null +++ b/.config/nvim/lua/config/plugins/fzflua.lua @@ -0,0 +1,29 @@ +return { + "ibhagwan/fzf-lua", + event = "VeryLazy", + dependencies = { "echasnovski/mini.icons" }, + opts = { + keymap = { + builtin = { + ["<S-j>"] = "preview-page-down", + ["<S-k>"] = "preview-page-up", + }, + }, + winopts = { + row = 1, + col = 0, + width = 1, + height = 0.4, + title_pos = "left", + preview = { + layout = "horizontal", + title_pos = "right", + }, + }, + files = { + -- Show hidden files but respect .gitignore + rg_opts = [[--color=never --hidden --files -g "!.git" --ignore-file ~/.config/git/ignore]], + fd_opts = [[--color=never --hidden --type f --type l --exclude .git --ignore-file ~/.config/git/ignore]], + }, + }, +} diff --git a/.config/nvim/lua/config/plugins/gitsigns.lua b/.config/nvim/lua/config/plugins/gitsigns.lua new file mode 100644 index 0000000..13c3b20 --- /dev/null +++ b/.config/nvim/lua/config/plugins/gitsigns.lua @@ -0,0 +1,36 @@ +return { + { + "lewis6991/gitsigns.nvim", + event = "VeryLazy", + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + on_attach = function(buffer) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + end + + -- stylua: ignore start + map("n", "]g", gs.next_hunk, "Next Hunk") + map("n", "[g", gs.prev_hunk, "Prev Hunk") + map({ "n", "v" }, "<leader>gs", ":Gitsigns stage_hunk<CR>", "Stage Hunk") + map({ "n", "v" }, "<leader>gr", ":Gitsigns reset_hunk<CR>", "Reset Hunk") + map("n", "<leader>gS", gs.stage_buffer, "Stage Buffer") + map("n", "<leader>gd", gs.diffthis, "Diff this") + map("n", "<leader>gu", gs.undo_stage_hunk, "Undo Stage Hunk") + map("n", "<leader>gR", gs.reset_buffer, "Reset Buffer") + map("n", "<leader>gp", gs.preview_hunk, "Preview Hunk") + map("n", "<leader>gb", function() gs.blame_line({ full = true }) end, "Blame Line") + map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk") + end, + }, + }, +} diff --git a/.config/nvim/lua/config/plugins/harpoon.lua b/.config/nvim/lua/config/plugins/harpoon.lua new file mode 100644 index 0000000..25168cc --- /dev/null +++ b/.config/nvim/lua/config/plugins/harpoon.lua @@ -0,0 +1,49 @@ +return { + "https://github.com/theprimeagen/harpoon", + branch = "harpoon2", + event = "VeryLazy", + config = function() + local harpoon = require("harpoon") + harpoon.setup({ + settings = { + save_on_toggle = true, + sync_on_ui_close = true, + key = function() + return vim.fn.getcwd() + end, + }, + }) + harpoon:setup() + + local list = harpoon:list("default") + local wk = require("which-key") + + wk.add({ + mode = { "n" }, + { + "<leader>a", + function() + list:add() + end, + hidden = true, + }, + { + "<leader><leader>", + function() + harpoon.ui:toggle_quick_menu(list) + end, + hidden = true, + }, + }) + for i = 1, 6 do + wk.add({ + "<leader>" .. i, + function() + list:select(i) + end, + hidden = true, + mode = "n", + }) + end + end, +} diff --git a/.config/nvim/lua/config/plugins/learn.lua b/.config/nvim/lua/config/plugins/learn.lua new file mode 100644 index 0000000..ebaf057 --- /dev/null +++ b/.config/nvim/lua/config/plugins/learn.lua @@ -0,0 +1,8 @@ +return { + { + "m4xshen/hardtime.nvim", + lazy = false, + dependencies = { "MunifTanjim/nui.nvim" }, + opts = {}, + }, +} diff --git a/.config/nvim/lua/config/plugins/lsp.lua b/.config/nvim/lua/config/plugins/lsp.lua new file mode 100644 index 0000000..dca3f5f --- /dev/null +++ b/.config/nvim/lua/config/plugins/lsp.lua @@ -0,0 +1,236 @@ +return { + "neovim/nvim-lspconfig", + event = "VeryLazy", + dependencies = { + { "williamboman/mason.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + { + "j-hui/fidget.nvim", + opts = { + notification = { + window = { + winblend = 0, + }, + }, + }, + }, + }, + config = function() + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or "n" + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + end + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press <C-t>. + map("gd", require("fzf-lua").lsp_definitions, "Goto Definition") + + map("gk", function() + vim.diagnostic.open_float() + end, "Open floating diagnostic") + + -- Find references for the word under your cursor. + map("gr", require("fzf-lua").lsp_references, "Goto References") + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map("gI", require("fzf-lua").lsp_implementations, "Goto Implementation") + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map("<leader>D", require("fzf-lua").lsp_typedefs, "Type Definition") + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map("<leader>ds", require("fzf-lua").lsp_document_symbols, "Document Symbols") + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map("<leader>ws", require("fzf-lua").lsp_live_workspace_symbols, "Workspace Symbols") + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map("gR", vim.lsp.buf.rename, "Rename") + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map("<leader>ca", vim.lsp.buf.code_action, "Code Action", { "n", "x" }) + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map("gD", vim.lsp.buf.declaration, "Goto Declaration") + local function client_supports_method(client, method, bufnr) + if vim.fn.has("nvim-0.11") == 1 then + return client:supports_method(method, bufnr) + else + return client.supports_method(method, { bufnr = bufnr }) + end + end + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if + client + and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) + then + local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd("LspDetach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) + end, + }) + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + vim.api.nvim_set_hl(0, "LspInlayHint", { fg = "#4c566a", bg = "NONE", italic = true }) + + -- This may be unwanted, since they displace some of your code + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then + map("<leader>th", function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) + end, "Toggle Inlay Hints") + end + end, + }) + + vim.keymap.set("n", "gK", function() + local new_config = not vim.diagnostic.config().virtual_lines + vim.diagnostic.config({ virtual_lines = new_config }) + end, { desc = "Toggle diagnostic virtual_lines" }) + + -- Diagnostic Config + -- See :help vim.diagnostic.Opts + vim.diagnostic.config({ + severity_sort = true, + float = { border = "rounded", source = "if_many" }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = " ", + [vim.diagnostic.severity.WARN] = " ", + [vim.diagnostic.severity.INFO] = " ", + [vim.diagnostic.severity.HINT] = " ", + }, + }, + virtual_text = { current_line = true }, + -- virtual_text = { + -- source = "if_many", + -- spacing = 2, + -- format = function(diagnostic) + -- local diagnostic_message = { + -- [vim.diagnostic.severity.ERROR] = diagnostic.message, + -- [vim.diagnostic.severity.WARN] = diagnostic.message, + -- [vim.diagnostic.severity.INFO] = diagnostic.message, + -- [vim.diagnostic.severity.HINT] = diagnostic.message, + -- } + -- return diagnostic_message[diagnostic.severity] + -- end, + -- }, + }) + local original_capabilities = vim.lsp.protocol.make_client_capabilities() + local capabilities = require("blink.cmp").get_lsp_capabilities(original_capabilities) + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - 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 = { + bashls = {}, + marksman = {}, + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`ts_ls`) will work just fine + -- ts_ls = {}, + -- + + lua_ls = { + -- cmd = { ... }, + -- filetypes = { ... }, + -- capabilities = {}, + -- settings = { + -- Lua = { + -- completion = { + -- callSnippet = 'Replace', + -- }, + -- -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- -- diagnostics = { disable = { 'missing-fields' } }, + -- }, + -- }, + }, + } + + -- Ensure the servers and tools above are installed + -- + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + -- + -- `mason` had to be setup earlier: to configure its options see the + -- `dependencies` table for `nvim-lspconfig` above. + -- + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + "stylua", + "prettierd", + }) + require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + + require("mason-lspconfig").setup({ + ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + automatic_installation = false, + handlers = { + function(server_name) + if server_name == "rust_analyzer" then + return + end + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for ts_ls) + server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, +} diff --git a/.config/nvim/lua/config/plugins/lualine.lua b/.config/nvim/lua/config/plugins/lualine.lua new file mode 100644 index 0000000..466d7b4 --- /dev/null +++ b/.config/nvim/lua/config/plugins/lualine.lua @@ -0,0 +1,218 @@ +return { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + dependencies = { "nvim-tree/nvim-web-devicons" }, + -- Eviline config for lualine + -- Author: shadmansaleh + -- Credit: glepnir + config = function() + local lualine = require("lualine") + + -- Color table for highlights + -- stylua: ignore + local colors = { + bg = '#434c5e', + fg = '#d8dee9', + yellow = '#ebcb8b', + cyan = '#88c0d0', + darkblue = '#5e81ac', + green = '#a3be8c', + orange = '#d08770', + violet = '#b48ead', + blue = '#81a1c1', + red = '#bf616a', + } + + local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand("%:p:h") + local gitdir = vim.fn.finddir(".git", filepath .. ";") + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, + } + + local config = { + options = { + component_separators = "", + section_separators = "", + theme = { + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + } + + -- Inserts a component in lualine_c at left section + local function ins_left(component) + table.insert(config.sections.lualine_c, component) + end + + -- Inserts a component in lualine_x at right section + local function ins_right(component) + table.insert(config.sections.lualine_x, component) + end + + -- ins_left({ + -- function() + -- return "▊" + -- end, + -- color = { fg = colors.blue }, -- Sets highlighting of component + -- padding = { left = 0, right = 1 }, -- We don't need space before this + -- }) + + ins_left({ + -- mode component + function() + return " " .. string.upper(vim.fn.mode()) + end, + color = function() + -- auto change color according to neovims mode + local mode_color = { + n = colors.red, + i = colors.green, + v = colors.blue, + [""] = colors.blue, + V = colors.blue, + c = colors.violet, + no = colors.red, + s = colors.orange, + S = colors.orange, + [""] = colors.orange, + ic = colors.yellow, + R = colors.violet, + Rv = colors.violet, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ["r?"] = colors.cyan, + ["!"] = colors.red, + t = colors.red, + } + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { right = 1 }, + }) + + ins_left({ + "filename", + cond = conditions.buffer_not_empty, + color = { fg = colors.green, gui = "bold" }, + }) + ins_left({ + "filesize", + cond = conditions.buffer_not_empty, + }) + + ins_right({ "location" }) + + ins_right({ "progress", color = { fg = colors.fg, gui = "bold" } }) + + ins_left({ + "diagnostics", + sources = { "nvim_diagnostic" }, + symbols = { error = " ", warn = " ", info = " " }, + diagnostics_color = { + error = { fg = colors.red }, + warn = { fg = colors.yellow }, + info = { fg = colors.cyan }, + }, + }) + -- + -- -- Insert mid section. You can make any number of sections in neovim :) + -- -- for lualine it's any number greater then 2 + -- ins_left({ + -- function() + -- return "%=" + -- end, + -- }) + -- + -- ins_left({ + -- -- Lsp server name . + -- function() + -- local msg = "No Active Lsp" + -- local buf_ft = vim.api.nvim_get_option_value("filetype", { buf = 0 }) + -- local clients = vim.lsp.get_clients() + -- if next(clients) == nil then + -- return msg + -- end + -- for _, client in ipairs(clients) do + -- local filetypes = client.config.filetypes + -- if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + -- return client.name + -- end + -- end + -- return msg + -- end, + -- icon = " LSP:", + -- color = { fg = "#ffffff", gui = "bold" }, + -- }) + + -- ins_right({ + -- "filetype", + -- color = { fg = colors.fg, gui = "bold" }, + -- }) + -- -- Add components to right sections + -- ins_right({ + -- "o:encoding", -- option component same as &encoding in viml + -- fmt = string.upper, -- I'm not sure why it's upper case either ;) + -- cond = conditions.hide_in_width, + -- color = { fg = colors.green, gui = "bold" }, + -- }) + -- + -- ins_right({ + -- "fileformat", + -- fmt = string.upper, + -- color = { fg = colors.green, gui = "bold" }, + -- }) + + -- ins_right({ + -- "branch", + -- icon = "", + -- color = { fg = colors.violet, gui = "bold" }, + -- }) + + -- ins_right({ + -- "diff", + -- symbols = { added = " ", modified = " ", removed = " " }, + -- diff_color = { + -- added = { fg = colors.green }, + -- modified = { fg = colors.orange }, + -- removed = { fg = colors.red }, + -- }, + -- cond = conditions.hide_in_width, + -- }) + + -- ins_right({ + -- function() + -- return "▊" + -- end, + -- color = { fg = colors.blue }, + -- padding = { left = 1 }, + -- }) + + lualine.setup(config) + end, +} diff --git a/.config/nvim/lua/config/plugins/luasnip.lua b/.config/nvim/lua/config/plugins/luasnip.lua new file mode 100644 index 0000000..a051cee --- /dev/null +++ b/.config/nvim/lua/config/plugins/luasnip.lua @@ -0,0 +1,21 @@ +return { + "L3MON4D3/LuaSnip", + version = "v2.*", + event = "VeryLazy", + build = "make install_jsregexp", + config = function() + require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/config/snippets/" }) + local ls = require("luasnip") + vim.keymap.set({ "i", "s" }, "<C-d>", function() + ls.jump(1) + end, { silent = true }) + vim.keymap.set({ "i", "s" }, "<C-u>", function() + ls.jump(-1) + end, { silent = true }) + ls.config.setup({ + enable_autosnippets = true, + region_check_events = "InsertEnter", + delete_check_events = "InsertLeave", + }) + end, +} diff --git a/.config/nvim/lua/config/plugins/markdown.lua b/.config/nvim/lua/config/plugins/markdown.lua new file mode 100644 index 0000000..223d3fb --- /dev/null +++ b/.config/nvim/lua/config/plugins/markdown.lua @@ -0,0 +1,220 @@ +return { + { + "bullets-vim/bullets.vim", + ft = "markdown", + config = function() + vim.g.bullets_delete_last_bullet_if_empty = 1 + end, + }, + { + "stevearc/conform.nvim", + event = "VeryLazy", + optional = true, + opts = { + formatters = { + ["markdownlint-cli2"] = { + condition = function(_, ctx) + local diag = vim.tbl_filter(function(d) + return d.source == "markdownlint" + end, vim.diagnostic.get(ctx.buf)) + return #diag > 0 + end, + }, + }, + formatters_by_ft = { + ["markdown"] = { "prettier", "markdownlint-cli2" }, + ["markdown.mdx"] = { "prettier", "markdownlint-cli2" }, + }, + }, + }, + { + "williamboman/mason.nvim", + event = "VeryLazy", + opts = { ensure_installed = { "markdownlint-cli2" } }, + }, + { + "nvimtools/none-ls.nvim", + event = "VeryLazy", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.markdownlint_cli2, + }) + end, + }, + { + "mfussenegger/nvim-lint", + event = "VeryLazy", + + optional = true, + opts = { + linters_by_ft = { + markdown = { "markdownlint-cli2" }, + }, + }, + }, + { + "neovim/nvim-lspconfig", + event = "VeryLazy", + + opts = { + servers = { + marksman = {}, + }, + }, + }, + + { + "iamcco/markdown-preview.nvim", + event = "VeryLazy", + + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = function() + require("lazy").load({ plugins = { "markdown-preview.nvim" } }) + vim.fn["mkdp#util#install"]() + end, + keys = { + { + "<leader>ow", + ft = "markdown", + "<cmd>MarkdownPreviewToggle<cr>", + desc = "Markdown Preview", + }, + }, + config = function() + vim.cmd([[do FileType]]) + end, + }, + + { + "MeanderingProgrammer/render-markdown.nvim", + ft = "markdown", + config = function() + require("render-markdown").setup({ + win_options = { + conceallevel = { + default = 0, -- Set default conceallevel to 0 + rendered = 3, -- Keep rendered mode at 3 + }, + }, + bullet = { + -- Turn on / off list bullet rendering + enabled = true, + }, + latex = { enabled = false }, + checkbox = { + -- Turn on / off checkbox state rendering + enabled = true, + -- Determines how icons fill the available space: + -- inline: underlying text is concealed resulting in a left aligned icon + -- overlay: result is left padded with spaces to hide any additional text + position = "inline", + unchecked = { + -- Replaces '[ ]' of 'task_list_marker_unchecked' + icon = " ", + -- Highlight for the unchecked icon + highlight = "RenderMarkdownUnchecked", + -- Highlight for item associated with unchecked checkbox + scope_highlight = nil, + }, + checked = { + -- Replaces '[x]' of 'task_list_marker_checked' + icon = " ", + -- Highlight for the checked icon + highlight = "RenderMarkdownChecked", + -- Highlight for item associated with checked checkbox + scope_highlight = nil, + }, + }, + html = { + -- Turn on / off all HTML rendering + enabled = true, + comment = { + -- Turn on / off HTML comment concealing + conceal = false, + }, + }, + heading = { + -- left_pad = 1, + sign = false, + icons = { " ", " ", " ", " ", " ", " " }, + backgrounds = { + "Headline1Bg", + "Headline2Bg", + "Headline3Bg", + "Headline4Bg", + "Headline5Bg", + "Headline6Bg", + }, + foregrounds = { + "Headline1Fg", + "Headline2Fg", + "Headline3Fg", + "Headline4Fg", + "Headline5Fg", + "Headline6Fg", + }, + }, + ft = { "markdown" }, + }) + + local color1_bg = "#bf616a" + local color2_bg = "#d08770" + local color5_bg = "#5e81ac" + local color4_bg = "#a3be8c" + local color6_bg = "#b48ead" + local color3_bg = "#ebcb8b" + local color_fg = "#2e3440" + + vim.cmd(string.format([[highlight @markup.strong guifg=%s]], color2_bg)) + vim.cmd(string.format([[highlight @markup.italic guifg=%s]], color2_bg)) + vim.cmd(string.format([[highlight RenderMarkdownCodeInline guifg=%s]], color4_bg)) + + -- Heading background color highlights + vim.cmd(string.format([[highlight Headline1Bg guifg=%s guibg=%s]], color_fg, color1_bg)) + vim.cmd(string.format([[highlight Headline2Bg guifg=%s guibg=%s]], color_fg, color2_bg)) + vim.cmd(string.format([[highlight Headline3Bg guifg=%s guibg=%s]], color_fg, color3_bg)) + vim.cmd(string.format([[highlight Headline4Bg guifg=%s guibg=%s]], color_fg, color4_bg)) + vim.cmd(string.format([[highlight Headline5Bg guifg=%s guibg=%s]], color_fg, color5_bg)) + vim.cmd(string.format([[highlight Headline6Bg guifg=%s guibg=%s]], color_fg, color6_bg)) + + -- Heading foreground color highlights (bold and with specific colors) + vim.cmd(string.format([[highlight Headline1Fg cterm=bold gui=bold guifg=%s]], color1_bg)) + vim.cmd(string.format([[highlight Headline2Fg cterm=bold gui=bold guifg=%s]], color2_bg)) + vim.cmd(string.format([[highlight Headline3Fg cterm=bold gui=bold guifg=%s]], color3_bg)) + vim.cmd(string.format([[highlight Headline4Fg cterm=bold gui=bold guifg=%s]], color4_bg)) + vim.cmd(string.format([[highlight Headline5Fg cterm=bold gui=bold guifg=%s]], color5_bg)) + vim.cmd(string.format([[highlight Headline6Fg cterm=bold gui=bold guifg=%s]], color6_bg)) + + vim.cmd(string.format([[highlight RenderMarkdownH1Bg guifg=%s guibg=%s]], color_fg, color1_bg)) + vim.cmd(string.format([[highlight RenderMarkdownH2Bg guifg=%s guibg=%s]], color_fg, color2_bg)) + vim.cmd(string.format([[highlight RenderMarkdownH3Bg guifg=%s guibg=%s]], color_fg, color3_bg)) + vim.cmd(string.format([[highlight RenderMarkdownH4Bg guifg=%s guibg=%s]], color_fg, color4_bg)) + vim.cmd(string.format([[highlight RenderMarkdownH5Bg guifg=%s guibg=%s]], color_fg, color5_bg)) + vim.cmd(string.format([[highlight RenderMarkdownH6Bg guifg=%s guibg=%s]], color_fg, color6_bg)) + + -- Apply custom foreground colors for headings (bold) + vim.cmd(string.format([[highlight RenderMarkdownH1 guifg=%s guibg=%s cterm=bold gui=bold]], color1_bg, color_fg)) + vim.cmd(string.format([[highlight RenderMarkdownH2 guifg=%s guibg=%s cterm=bold gui=bold]], color2_bg, color_fg)) + vim.cmd(string.format([[highlight RenderMarkdownH3 guifg=%s guibg=%s cterm=bold gui=bold]], color3_bg, color_fg)) + vim.cmd(string.format([[highlight RenderMarkdownH4 guifg=%s guibg=%s cterm=bold gui=bold]], color4_bg, color_fg)) + vim.cmd(string.format([[highlight RenderMarkdownH5 guifg=%s guibg=%s cterm=bold gui=bold]], color5_bg, color_fg)) + vim.cmd(string.format([[highlight RenderMarkdownH6 guifg=%s guibg=%s cterm=bold gui=bold]], color6_bg, color_fg)) + Snacks.toggle({ + name = "Render Markdown", + get = function() + return require("render-markdown.state").enabled + end, + set = function(enabled) + local m = require("render-markdown") + if enabled then + m.enable() + else + m.disable() + end + end, + }):map("<leader>or", { desc = "Toggle Render Markdown" }) + end, + }, +} diff --git a/.config/nvim/lua/config/plugins/mini.lua b/.config/nvim/lua/config/plugins/mini.lua new file mode 100644 index 0000000..fe6a3aa --- /dev/null +++ b/.config/nvim/lua/config/plugins/mini.lua @@ -0,0 +1,27 @@ +return { + { + "echasnovski/mini.nvim", + event = "VeryLazy", + enabled = true, + config = function() + require("mini.icons").setup() + require("mini.move").setup() + require("mini.ai").setup() + require("mini.surround").setup() + require("mini.pairs").setup() + -- + -- HACK: The Key Commands -> for help run ;h nvim-surround.usage + -- + -- Old text Command New text + -- -------------------------------------------------------------------------------- + -- surr*ound_words ysiw) (surround_words) + -- *make strings ys$" "make strings" + -- [delete ar*ound me!] ds] delete around me! + -- remove <b>HTML t*ags</b> dst remove HTML tags + -- 'change quot*es' cs'" "change quotes" + -- <b>or tag* types</b> csth1<CR> <h1>or tag types</h1> + -- delete(functi*on calls) dsf function calls + -- + end, + }, +} diff --git a/.config/nvim/lua/config/plugins/obsidian.lua b/.config/nvim/lua/config/plugins/obsidian.lua new file mode 100644 index 0000000..64992fc --- /dev/null +++ b/.config/nvim/lua/config/plugins/obsidian.lua @@ -0,0 +1,42 @@ +return { + "epwalsh/obsidian.nvim", + event = "VeryLazy", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "ibhagwan/fzf-lua", + }, + opts = { + ui = { enable = false }, + daily_notes = { + date_format = "%Y-%m-%d", + alias_format = "%B %-d, %Y", + default_tags = { "daily" }, + template = nil, + folder = "daily", + }, + dir = "$HOME/Library/Mobile Documents/iCloud~md~obsidian/Documents/Obsidian/", + mappings = {}, + follow_url_func = function(url) + -- Open the URL in the default web browser. + -- if URL contains @ it should be replaced with %40 + vim.fn.jobstart({ "open", url }) -- Mac OS + end, + note_id_func = function(title) + -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. + -- In this case a note with the title 'My new note' will be given an ID that looks + -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' + local suffix = "" + if title ~= nil then + -- If title is given, transform it into valid file name. + suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() + else + -- If title is nil, just add 4 random uppercase letters to the suffix. + for _ = 1, 4 do + suffix = suffix .. string.char(math.random(65, 90)) + end + end + return tostring(os.time()) .. "-" .. suffix + end, + }, +} diff --git a/.config/nvim/lua/config/plugins/oil.lua b/.config/nvim/lua/config/plugins/oil.lua new file mode 100644 index 0000000..555768f --- /dev/null +++ b/.config/nvim/lua/config/plugins/oil.lua @@ -0,0 +1,37 @@ +return { + "stevearc/oil.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("oil").setup({ + default_file_explorer = true, + keymaps = { + ["l"] = "actions.select", + ["h"] = "actions.parent", + ["<CR>"] = "actions.select", + ["<C-s>"] = nil, + ["<C-h>"] = nil, + ["<C-l>"] = nil, + }, + delete_to_trash = true, + view_options = { + show_hidden = true, + }, + skip_confirm_for_simple_edits = true, + float = { + max_width = 80, + max_height = 30, + override = function(conf) + return conf + end, + }, + }) + vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" }) + + vim.api.nvim_create_autocmd("FileType", { + pattern = "oil", + callback = function() + vim.opt_local.cursorline = true + end, + }) + end, +} diff --git a/.config/nvim/lua/config/plugins/rustacean.lua b/.config/nvim/lua/config/plugins/rustacean.lua new file mode 100644 index 0000000..849db6e --- /dev/null +++ b/.config/nvim/lua/config/plugins/rustacean.lua @@ -0,0 +1,5 @@ +return { + "mrcjkb/rustaceanvim", + version = "^6", -- Recommended + lazy = false, -- This plugin is already lazy +} diff --git a/.config/nvim/lua/config/plugins/snacks.lua b/.config/nvim/lua/config/plugins/snacks.lua new file mode 100644 index 0000000..b83beb9 --- /dev/null +++ b/.config/nvim/lua/config/plugins/snacks.lua @@ -0,0 +1,83 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + opts = { + bigfile = { enabled = true }, + notifier = { timeout = 2000 }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + image = { + enabled = true, + doc = { + enabled = true, + float = true, + inline = false, + max_width = 60, + max_height = 30, + }, + }, + dashboard = { + enabled = true, + autokeys = "wert", + preset = { + keys = { + { icon = " ", key = "f", desc = "Find File", action = ":lua Snacks.dashboard.pick('files')" }, + { icon = " ", key = "g", desc = "Grep", action = ":lua Snacks.dashboard.pick('live_grep')", padding = 1 }, + { icon = " ", key = "n", desc = "New File", action = ":ene | startinsert" }, + { icon = " ", key = "l", desc = "Lazy", action = ":Lazy", enabled = package.loaded.lazy ~= nil }, + { icon = " ", key = "q", desc = "Quit", action = ":qa" }, + }, + }, + formats = { + key = function(item) + return { { "[", hl = "special" }, { item.key, hl = "key" }, { "]", hl = "special" } } + end, + }, + sections = { + { section = "recent_files", limit = 4, padding = 1 }, + { section = "keys", padding = 1 }, + { section = "startup" }, + }, + }, + styles = { + snacks_image = { + relative = "editor", + col = -1, + }, + lazygit = { + wo = { + winhighlight = "NormalFloat:None,FloatBorder:SnacksInputBorder,FloatTitle:SnacksInputTitle", + cursorline = false, + }, + }, + float = { + backdrop = false, + }, + blame_line = { + backdrop = false, + }, + }, + }, + init = function() + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + vim.print = _G.dd + Snacks.toggle.option("spell", { name = "Spelling" }):map("<leader>ts") + Snacks.toggle.option("wrap", { name = "Wrap" }):map("<leader>tw") + Snacks.toggle.diagnostics():map("<leader>td") + Snacks.toggle + .option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }) + :map("<leader>tc") + Snacks.toggle.indent():map("<leader>ti") + end, + }) + end, +} diff --git a/.config/nvim/lua/config/plugins/treesitter.lua b/.config/nvim/lua/config/plugins/treesitter.lua new file mode 100644 index 0000000..3c95b41 --- /dev/null +++ b/.config/nvim/lua/config/plugins/treesitter.lua @@ -0,0 +1,41 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + event = "VeryLazy", + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "c", + "lua", + "vim", + "vimdoc", + "query", + "markdown", + "markdown_inline", + "rust", + }, + auto_install = true, + incremental_selection = { + enable = true, + keymaps = { + node_incremental = "<Enter>", + scope_incremental = false, + node_decremental = "<Backspace>", + }, + }, + highlight = { + enable = true, + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + additional_vim_regex_highlighting = false, + }, + }) + end, + }, +} diff --git a/.config/nvim/lua/config/plugins/typst.lua b/.config/nvim/lua/config/plugins/typst.lua new file mode 100644 index 0000000..2443773 --- /dev/null +++ b/.config/nvim/lua/config/plugins/typst.lua @@ -0,0 +1,9 @@ +return { + "chomosuke/typst-preview.nvim", + -- lazy = false, -- or ft = 'typst' + ft = "typst", + version = "1.*", + opts = { + invert_colors = "auto", + }, -- lazy.nvim will implicitly calls `setup {}` +} diff --git a/.config/nvim/lua/config/plugins/ufo.lua b/.config/nvim/lua/config/plugins/ufo.lua new file mode 100644 index 0000000..21380b8 --- /dev/null +++ b/.config/nvim/lua/config/plugins/ufo.lua @@ -0,0 +1,28 @@ +return { + -- { + -- event = "VeryLazy", + -- "kevinhwang91/nvim-ufo", + -- dependencies = { + -- "kevinhwang91/promise-async", + -- }, + -- config = function() + -- require("ufo").setup({ + -- -- treesitter not required + -- -- ufo uses the same query files for folding (queries/<lang>/folds.scm) + -- -- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`- + -- provider_selector = function(_, _, _) + -- return { "treesitter", "indent" } + -- end, + -- open_fold_hl_timeout = 0, -- Disable highlight timeout after opening + -- }) + -- + -- vim.o.foldenable = true + -- vim.o.foldcolumn = "0" -- '0' is not bad + -- vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value + -- vim.o.foldlevelstart = 99 + -- + -- vim.keymap.set("n", "zR", require("ufo").openAllFolds) + -- vim.keymap.set("n", "zM", require("ufo").closeAllFolds) + -- end, + -- }, +} diff --git a/.config/nvim/lua/config/plugins/utils.lua b/.config/nvim/lua/config/plugins/utils.lua new file mode 100644 index 0000000..fd57680 --- /dev/null +++ b/.config/nvim/lua/config/plugins/utils.lua @@ -0,0 +1,71 @@ +return { + { + "ojroques/nvim-osc52", + event = "VeryLazy", + config = function() + vim.keymap.set("v", "Y", require("osc52").copy_visual) + end, + }, + { -- For CSS colors + "NvChad/nvim-colorizer.lua", + event = "BufReadPre", + opts = { + user_default_options = { + names = false, + tailwind = "both", + css = true, + css_fn = true, + mode = "background", + }, + }, + }, + { -- for file outline + "hedyhli/outline.nvim", + event = "VeryLazy", + opts = {}, + }, + { -- Undotree + "mbbill/undotree", + event = "VeryLazy", + config = function() + vim.g.undotree_SplitWidth = 50 + vim.g.undotree_WindowLayout = 3 + end, + }, + { -- for diagnostics + event = "VeryLazy", + "folke/trouble.nvim", + opts = {}, + cmd = "Trouble", + keys = { + { + "<leader>h", + "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", + desc = "Buffer Diagnostics (Trouble)", + }, + }, + }, + { -- for colored brackets and divs + "HiPhish/rainbow-delimiters.nvim", + event = "VeryLazy", + }, + { -- for tmux navigation + event = "VeryLazy", + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + "TmuxNavigatorProcessList", + }, + keys = { + { "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" }, + { "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" }, + { "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" }, + { "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" }, + { "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" }, + }, + }, +} diff --git a/.config/nvim/lua/config/plugins/which-key.lua b/.config/nvim/lua/config/plugins/which-key.lua new file mode 100644 index 0000000..47098fb --- /dev/null +++ b/.config/nvim/lua/config/plugins/which-key.lua @@ -0,0 +1,29 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + win = { + wo = { + winblend = 0, + }, + }, + preset = "helix", + icons = { + rules = false, + }, + delay = 500, + spec = { + { "<leader>c", group = "Code", mode = { "n", "x" } }, + { "<leader>d", group = "Document" }, + { "<leader>g", group = "Git" }, + { "<leader>m", group = "Marks" }, + { "<leader>o", group = "Obsidian" }, + { "<leader>r", group = "Rename" }, + { "<leader>s", group = "Search" }, + { "<leader>t", group = "Toggle" }, + { "<leader>w", group = "Workspace" }, + { "<leader>l", group = "LSP" }, + { "<leader>x", group = "Trouble" }, + }, + }, +} diff --git a/.config/nvim/lua/config/snippets/all.lua b/.config/nvim/lua/config/snippets/all.lua new file mode 100644 index 0000000..e2a2ef1 --- /dev/null +++ b/.config/nvim/lua/config/snippets/all.lua @@ -0,0 +1,10 @@ +local ls = require("luasnip") +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node + +return { + s("hi", { + t("Hello, world!"), + }), +} diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..31832c1 --- /dev/null +++ b/.config/nvim/lua/mappings.lua @@ -0,0 +1,143 @@ +local wk = require("which-key") + +vim.keymap.set("n", "x", '"_x', { noremap = true, silent = true }) +vim.keymap.set("x", "x", '"_x', { noremap = true, silent = true }) +vim.keymap.set("v", "x", '"_x', { noremap = true, silent = true }) +vim.keymap.set("n", "c", '"_c') +vim.keymap.set("n", "C", '"_C') +vim.keymap.set("n", "cc", '"_cc') +vim.keymap.set("x", "c", '"_c') +vim.keymap.set("n", "<leader>q", vim.cmd.wq, { desc = "Save and quit" }) + +-- for searching all files, hidden aswell +local fzf = require("fzf-lua") +vim.keymap.set("n", "<leader>sa", function() + fzf.files({ fd_opts = "--no-ignore --hidden --type f --type l" }) +end, { desc = "Search including ignored files" }) + +wk.add({ + { + mode = { "v" }, + { "<", "<gv", hidden = true }, + { ">", ">gv", hidden = true }, + { "P", '"_dP', hidden = true }, + }, + { + mode = { "n" }, + { "<leader>-", "<CMD>Oil --float<CR>", desc = "Open directory in float" }, + { "<C-d>", "<C-d>zz", desc = "Move down in buffer with cursor centered" }, + { "<C-u>", "<C-u>zz", desc = "Move up in buffer with cursor centered" }, + { "n", "nzzzv", desc = "Search next with cursor centered" }, + { "N", "Nzzzv", desc = "Search previous with cursor centered" }, + { "<leader>u", "<cmd>UndotreeToggle<CR>", desc = "Toggle undo tree" }, + { "<leader>oo", "<cmd>Outline<CR>", desc = "Toggle Outline" }, + { "<leader>on", "<cmd>ObsidianNew<CR>", desc = "New Obsidian File" }, + { "<leader>ol", "<cmd>ObsidianFollowLink<CR>", desc = "Follow Link" }, + { "<leader>ob", "<cmd>ObsidianBacklinks<CR>", desc = "Search backlinks" }, + { "<leader>ov", "<cmd>ObsidianLinks<CR>", desc = "Search backlinks" }, + { "<leader>ot", "<cmd>ObsidianTag<CR>", desc = "Search Obsidian Tags" }, + { "<leader>os", "<cmd>ObsidianSearch<CR>", desc = "Search Obsidian Files" }, + { "<leader>od", "<cmd>ObsidianToday<CR>", desc = "Open Daily Note" }, + { "<leader>oi", "<cmd>ObsidianPasteImg<CR>", desc = "Paste Image" }, + { + "<leader>of", + function() + local line = vim.api.nvim_get_current_line() + local pattern = "%(([^)]+)%)" + local _, _, path = string.find(line, pattern) + if path then + local absolute_path = "/Users/tomiko/Library/Mobile Documents/iCloud~md~obsidian/Documents/Obsidian/" .. path + local command = "!open '" .. absolute_path .. "'" + -- local command = "!open '" .. path .. "'" -- could also open relative + vim.cmd("silent " .. command) + end + end, + desc = "Open File", + }, + + { "<Esc>", "<cmd>nohlsearch<CR>", hidden = true }, -- Unhighlight + { "<C-h>", "<C-w><C-h>", hidden = true }, -- Move to left window + { "<C-l>", "<C-w><C-l>", hidden = true }, -- Move to right window + { "<C-j>", "<C-w><C-j>", hidden = true }, -- Move to lower window + { "<C-k>", "<C-w><C-k>", hidden = true }, -- Move to upper window + { "<C-q>", "<C-w><C-q>", hidden = true }, -- Close window + { + "<leader>sb", + function() + require("fzf-lua").buffers() + end, + desc = "Search Buffers", + }, + { + "<leader>sk", + function() + require("fzf-lua").keymaps() + end, + desc = "Search Keymaps", + }, + { + "<leader>ss", + function() + require("fzf-lua").files() + end, + desc = "Search Files", + }, + { + "<leader>sw", + function() + require("fzf-lua").grep_curbuf() + end, + desc = "Search current Word", + }, + { + "<leader>sg", + function() + require("fzf-lua").live_grep_native() + end, + desc = "Search by Grep", + }, + { + "<leader>sx", + function() + require("fzf-lua").lsp_document_diagnostics() + end, + desc = "Search Diagnostics", + }, + { + "<leader>sd", + function() + require("fzf-lua").lsp_workspace_diagnostics() + end, + desc = "Search Diagnostics", + }, + { + "<leader>sr", + function() + require("fzf-lua").oldfiles() + end, + desc = "Search Recent Files", + }, + { + "<leader>n", + function() + Snacks.notifier.show_history() + end, + desc = "Notification History", + }, + { + "<leader>gg", + function() + Snacks.lazygit() + end, + desc = "Lazygit", + }, + + { + "<leader>gl", + function() + Snacks.lazygit.log() + end, + desc = "Lazygit Log", + }, + }, +}) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua new file mode 100644 index 0000000..c61f4c9 --- /dev/null +++ b/.config/nvim/lua/options.lua @@ -0,0 +1,36 @@ +local set = vim.opt +local g = vim.g + +g.mapleader = " " +g.maplocalleader = " " +g.have_nerd_font = true +set.number = true +set.relativenumber = true +set.termguicolors = true +set.tabstop = 4 +set.shiftwidth = 4 +set.swapfile = false +set.expandtab = true +set.mouse = "a" +set.showmode = false +set.breakindent = true +set.undofile = true +set.ignorecase = true +set.smartcase = true +set.signcolumn = "yes" +set.updatetime = 250 +set.timeoutlen = 300 +set.splitright = true +set.splitbelow = true +set.list = true +set.listchars = { tab = "» ", trail = "·", nbsp = "␣" } +set.inccommand = "split" +set.cursorline = true +set.scrolloff = 4 +set.sidescrolloff = 4 +set.conceallevel = 2 +set.wrap = false + +vim.schedule(function() + set.clipboard = "unnamedplus" +end) |
