diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore deleted file mode 100644 index cb39c01..0000000 --- a/.config/nvim/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -lazy-lock.json -lua/dev diff --git a/.config/nvim/.luarc.json b/.config/nvim/.luarc.json deleted file mode 100644 index ebc872a..0000000 --- a/.config/nvim/.luarc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", - "runtime.version": "LuaJIT", - "diagnostics.globals": [ - "vim", - "numbers" - ], - "diagnostics.disable": [ - "missing-fields" - ] -} diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 28c35ba..aace41f 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,5 +1,641 @@ -require("core.variables") -require("core.keymaps") -require("core.autocmds") -require('core.package_manager') -require('winbar') +vim.g.mapleader = " " + +vim.opt.termguicolors = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.wrap = false +vim.opt.conceallevel = 2 +vim.opt.concealcursor = 'nc' +vim.opt.signcolumn = "yes" +vim.o.laststatus = 1 +vim.o.winborder = nil + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.iskeyword:append("_") +vim.opt.scrolloff = 10 +vim.opt.sidescrolloff = 10 +vim.opt.smoothscroll = true + +vim.opt.undodir = os.getenv("XDG_STATE_HOME") .. "/nvim/undodir" +vim.opt.undofile = true +vim.opt.backup = true +vim.opt.backupdir = os.getenv("XDG_STATE_HOME") .. "/nvim/backupdir" +vim.opt.autoread = true +vim.opt.swapfile = false + +vim.opt.formatoptions:remove("ro") + +-- keymaps -- +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "", "cnextzz") + +vim.keymap.set("n", "", "bp") +vim.keymap.set("n", "", "bn") + +vim.keymap.set("i", "jk", "") + +vim.keymap.set({ 'n', 'x' }, 'gy', '"+y', { desc = 'Copy to system clipboard' }) +vim.keymap.set('n', 'gp', '"+p', { desc = 'Paste from system clipboard' }) +vim.keymap.set('x', 'gp', '"+P', { desc = 'Paste from system clipboard' }) + +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "G", "Gzz") + +vim.keymap.set("n", "x", "source %") +vim.keymap.set("n", "x", ":.lua") +vim.keymap.set("v", "x", ":lua") + +vim.keymap.set("v", "", function() + for _ = 1, vim.fn.getpos("'>")[2] - vim.fn.getpos("'<")[2] - 1 do + vim.api.nvim_command("normal! J") + end +end) + +-- autocmds -- +vim.api.nvim_create_autocmd("VimLeavePre", { + pattern = "*", + callback = function() + if vim.g.savesession then + vim.api.nvim_command("mks! .session.vim") + end + end +}) + +-- pack hooks -- +vim.api.nvim_create_autocmd('PackChanged', { + callback = function(ev) + local name, kind = ev.data.spec.name, ev.data.kind + if name == 'nvim-treesitter' and kind == 'update' then + if not ev.data.active then vim.cmd.packadd('nvim-treesitter') end + vim.cmd('TSUpdate') + end + end +}) + +-- plugins -- +vim.pack.add({ + 'https://github.com/sainnhe/gruvbox-material', + 'https://github.com/sainnhe/everforest', + 'https://github.com/navarasu/onedark.nvim', + { src = 'https://github.com/echasnovski/mini.icons', version = vim.version.range('*') }, + 'https://github.com/folke/snacks.nvim', + 'https://github.com/rachartier/tiny-glimmer.nvim', + { src = 'https://github.com/echasnovski/mini.surround', version = vim.version.range('*') }, + { src = 'https://github.com/echasnovski/mini.pairs', version = vim.version.range('*') }, + { src = 'https://github.com/echasnovski/mini.ai', version = 'HEAD' }, + 'https://github.com/tpope/vim-abolish', + 'https://github.com/mbbill/undotree', + { src = 'https://github.com/ThePrimeagen/harpoon', version = 'harpoon2' }, + 'https://github.com/stevearc/oil.nvim', + 'https://github.com/mrjones2014/smart-splits.nvim', + 'https://github.com/ibhagwan/fzf-lua', + 'https://github.com/nvim-treesitter/nvim-treesitter', + 'https://github.com/nvim-treesitter/nvim-treesitter-textobjects', + 'https://github.com/neovim/nvim-lspconfig', + 'https://github.com/folke/lazydev.nvim', + 'https://github.com/smjonas/inc-rename.nvim', + 'https://github.com/williamboman/mason.nvim', + { src = 'https://github.com/saghen/blink.cmp', version = vim.version.range('*') }, + 'https://github.com/rafamadriz/friendly-snippets', + 'https://github.com/stevearc/conform.nvim', + 'https://github.com/mfussenegger/nvim-lint', + 'https://github.com/barreiroleo/ltex-extra.nvim', + 'https://github.com/mfussenegger/nvim-dap', + 'https://github.com/igorlfs/nvim-dap-view', + 'https://github.com/lervag/vimtex', + { src = 'https://github.com/chomosuke/typst-preview.nvim', version = vim.version.range('1.*') }, + 'https://github.com/tpope/vim-fugitive', + 'https://github.com/FabijanZulj/blame.nvim', + 'https://github.com/folke/todo-comments.nvim', + 'https://github.com/nvim-lua/plenary.nvim', + 'https://github.com/nvim-tree/nvim-web-devicons', +}) + +-- colorscheme -- +require('onedark').setup({ style = 'dark' }) +require('onedark').load() + +-- mini -- +require('mini.icons').setup() +require('mini.surround').setup() + +require('mini.pairs').setup({ + mappings = { + ["("] = { action = "open", pair = "()", neigh_pattern = "[^\\][%s%)%]%}]" }, + ["["] = { action = "open", pair = "[]", neigh_pattern = "[^\\][%s%)%]%}]" }, + ["{"] = { action = "open", pair = "{}", neigh_pattern = "[^\\][%s%)%]%}]" }, + [")"] = { action = "close", pair = "()", neigh_pattern = "[^\\]." }, + ["]"] = { action = "close", pair = "[]", neigh_pattern = "[^\\]." }, + ["}"] = { action = "close", pair = "{}", neigh_pattern = "[^\\]." }, + ['"'] = { action = "closeopen", pair = '""', neigh_pattern = "[^%w][^%w]", register = { cr = false } }, + ["'"] = { action = "closeopen", pair = "''", neigh_pattern = "[^%w][^%w]", register = { cr = false } }, + ["`"] = { action = "closeopen", pair = "``", neigh_pattern = "[^%w][^%w]", register = { cr = false } }, + }, +}) +vim.keymap.set('n', 'S', 'saiw', { silent = true }) + +local gen_spec = require('mini.ai').gen_spec +require('mini.ai').setup({ + custom_textobjects = { + F = gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }), + }, + n_lines = 1000 +}) + +-- snacks -- +require('snacks').setup({ + bigfile = { enabled = true }, + notifier = { enabled = true }, + notify = { enabled = true }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + input = { enabled = true }, + image = { + doc = { + inline = false, + float = true, + max_width = 10, + max_height = 5, + } + }, + words = { + debounce = 10 + } +}) + +-- tiny-glimmer -- +require('tiny-glimmer').setup({ + overwrite = { + search = { enabled = true }, + undo = { enabled = true }, + redo = { enabled = true }, + } +}) + +-- treesitter -- +require('nvim-treesitter.config').setup({ + auto_install = true, + highlight = { + enable = true, + disable = { "latex" }, + use_languagetree = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + indent = { enable = true }, +}) + +-- fzf-lua -- +local fzflua = require('fzf-lua') +fzflua.register_ui_select() +fzflua.setup({ + defaults = { + winopts = { + border = "rounded", + width = 0.6, + height = 0.5, + }, + }, + files = { + previewer = false, + winopts = { width = 0.5, height = 0.5 }, + }, + grep = { + winopts = { + width = 0.7, + preview = { + layout = "horizontal", + horizontal = "right:40%", + }, + }, + }, +}) +vim.keymap.set('n', 'ff', fzflua.files) +vim.keymap.set('n', 'fe', fzflua.diagnostics_workspace) +vim.keymap.set('n', 'fg', fzflua.live_grep) +vim.keymap.set('n', 'fb', fzflua.buffers) +vim.keymap.set('n', 'fh', fzflua.help_tags) +vim.keymap.set({ 'n', 'v' }, 'fc', fzflua.commands) + +-- lsp -- +require('lazydev').setup({ + library = { + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, +}) + +require('inc_rename').setup({ save_in_cmdline_history = false }) +require('mason').setup() + +local capabilities = require('blink.cmp').get_lsp_capabilities(nil, true) + +vim.lsp.config["gopls"] = { + capabilities = capabilities, + settings = { + gopls = { + ["ui.completion.usePlaceholders"] = true, + ["ui.diagnostic.staticcheck"] = true, + ["ui.inlayhint.hints"] = { + assignVariablesTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + completeUnimported = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + }, + }, +} +vim.lsp.enable('gopls') + +vim.lsp.config["lua_ls"] = { + capabilities = capabilities, + settings = { + Lua = { hint = { enable = true } }, + }, +} +vim.lsp.enable('lua_ls') + +vim.lsp.config["ltex"] = { + capabilities = capabilities, + on_attach = function() require("ltex_extra").setup() end, + settings = { + ltex = { + language = "en-GB", + additionalRules = { + enablePickyRules = true, + languageModel = '~/Downloads/ngrams/', + }, + }, + }, +} +vim.lsp.enable('ltex') + +vim.lsp.config["hls"] = { + capabilities = capabilities, + filetypes = { 'haskell', 'lhaskell', 'cabal' }, +} +vim.lsp.enable('hls') + +vim.lsp.config["texlab"] = { capabilities = capabilities } +vim.lsp.enable('texlab') + +vim.lsp.config["bashls"] = { capabilities = capabilities } +vim.lsp.enable('bashls') + +vim.lsp.config["zls"] = { capabilities = capabilities } +vim.lsp.enable('zls') + +vim.lsp.config["pyright"] = { capabilities = capabilities } +vim.lsp.enable('pyright') + +vim.lsp.config['clangd'] = { capabilities = capabilities } +vim.lsp.enable('clangd') + +vim.lsp.config['nil_ls'] = { capabilities = capabilities } +vim.lsp.enable('nil_ls') + +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + local conform = require("conform") + + local function jumpWithVirtLineDiags(jumpCount) + pcall(vim.api.nvim_del_augroup_by_name, "jumpWithVirtLineDiags") + vim.diagnostic.jump({ count = jumpCount }) + local initialVirtTextConf = vim.diagnostic.config().virtual_text + vim.diagnostic.config({ + virtual_text = false, + virtual_lines = { current_line = true }, + }) + vim.defer_fn(function() + vim.api.nvim_create_autocmd("CursorMoved", { + once = true, + group = vim.api.nvim_create_augroup("jumpWithVirtLineDiags", {}), + callback = function() + vim.diagnostic.config({ virtual_lines = false, virtual_text = initialVirtTextConf }) + end, + }) + end, 1) + end + + local bufopts = { noremap = true, silent = true, buffer = ev.buf } + vim.keymap.set("n", "e", vim.diagnostic.open_float, bufopts) + vim.keymap.set("n", "q", vim.diagnostic.setloclist, bufopts) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) + vim.keymap.set("n", "gr", fzflua.lsp_references, bufopts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) + vim.keymap.set("n", "gi", fzflua.lsp_implementations, bufopts) + vim.keymap.set("n", "k", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", function() return ":IncRename " .. vim.fn.expand("") end, { expr = true }) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set("n", "ge", function() jumpWithVirtLineDiags(1) end, bufopts) + vim.keymap.set("n", "gE", function() jumpWithVirtLineDiags(-1) end, bufopts) + vim.keymap.set("n", "fo", function() conform.format({ lsp_fallback = true }) end, bufopts) + end, +}) + +-- blink.cmp -- +require('blink.cmp').setup({ + keymap = { + preset = 'default', + [''] = {}, + [''] = {}, + [''] = { 'scroll_documentation_up', 'fallback' }, + [''] = { 'scroll_documentation_down', 'fallback' }, + }, + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = 'mono', + }, + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + providers = { + lazydev = { + name = "LazyDev", + module = "lazydev.integrations.blink", + fallbacks = { "lsp" }, + }, + }, + }, + signature = { + enabled = true, + window = { show_documentation = false }, + }, + cmdline = { + completion = { menu = { auto_show = true } }, + }, + completion = { + accept = { auto_brackets = { enabled = true } }, + menu = { + border = "single", + winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", + winblend = 0, + draw = { + treesitter = { 'lsp' }, + columns = { { 'kind_icon' }, { 'label' } }, + components = { + kind_icon = { + ellipsis = false, + text = function(ctx) + local kind_icon = require('mini.icons').get('lsp', ctx.kind) + return kind_icon + end, + highlight = function(ctx) + local _, hl = require('mini.icons').get('lsp', ctx.kind) + return hl + end, + }, + }, + }, + }, + documentation = { + auto_show = true, + window = { + border = 'single', + max_width = 160, + max_height = 30, + winblend = 0, + winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", + }, + }, + }, +}) + +-- conform -- +require('conform').setup({ + formatters_by_ft = { + python = { "black" }, + haskell = { "fourmolu" }, + javascript = { "prettierd" }, + markdown = { "mdformat" }, + rust = { "rustfmt" }, + go = { "gofmt" }, + json = { "jq" }, + bash = { "shfmt", "beautysh" }, + zsh = { "beautysh" }, + }, +}) + +-- lint -- +local lint = require('lint') +lint.linters_by_ft = { go = { "golangcilint" } } + +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = vim.api.nvim_create_augroup("lint", { clear = true }), + callback = function() lint.try_lint() end, +}) +vim.keymap.set("n", "li", function() lint.try_lint() end, { desc = "Trigger linting" }) + +-- dap -- +local dap = require('dap') +dap.adapters.codelldb = { + type = "server", + port = "${port}", + executable = { + command = vim.fn.expand("~/.local/share/nvim/mason/bin/codelldb"), + args = { "--port", "${port}" }, + }, +} +dap.configurations.c = { + { + name = "Launch", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + }, +} +dap.configurations.cpp = dap.configurations.c + +require('dap-view').setup({ + winbar = { controls = { enabled = true } }, + auto_toggle = true, +}) + +-- vimtex -- +if vim.loop.os_uname().sysname == "Darwin" then + vim.g.vimtex_view_method = 'sioyek' +else + vim.g.vimtex_view_method = 'zathura' +end +vim.g.vimtex_quickfix_ignore_filters = { 'Overfull', 'Underfull' } +vim.g.vimtex_quickfix_open_on_warning = 0 +vim.g.vimtex_compiler_method = 'latexmk' +vim.g.vimtex_compiler_latexmk = { + out_dir = 'build', + options = { + "-verbose", + "-shell-escape", + "-file-line-error", + "-synctex=1", + "-interaction=nonstopmode", + }, +} +vim.g.vimtex_view_automatic = 1 + +-- typst-preview -- +require('typst-preview').setup({ + extra_args = { "--font-path=fonts" }, + invert_colors = '{"rest": "auto","image": "never"}', +}) + +-- harpoon -- +local harpoon = require('harpoon') +harpoon:setup() +vim.keymap.set("n", "a", function() harpoon:list():add() end) +vim.keymap.set("n", "", 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) + +-- oil -- +require('oil').setup({ + float = { preview_split = "right" }, +}) + +local function open_oil_split() + local width = math.floor(vim.o.columns * 0.2) + vim.cmd("vsplit") + vim.cmd(string.format("vertical resize %d", width)) + require("oil").open() +end + +vim.keymap.set('n', 'o', function() require("oil").open_float() end) +vim.keymap.set('n', 'O', open_oil_split) + +-- smart-splits -- +local splits = require('smart-splits') +splits.setup() +vim.keymap.set('n', '', splits.resize_left) +vim.keymap.set('n', '', splits.resize_down) +vim.keymap.set('n', '', splits.resize_up) +vim.keymap.set('n', '', splits.resize_right) +vim.keymap.set('n', '', splits.move_cursor_left) +vim.keymap.set('n', '', splits.move_cursor_down) +vim.keymap.set('n', '', splits.move_cursor_up) +vim.keymap.set('n', '', splits.move_cursor_right) + +-- git -- +require('blame').setup() +require('todo-comments').setup() +vim.keymap.set("n", "]t", function() require("todo-comments").jump_next() end, { desc = "Next todo comment" }) +vim.keymap.set("n", "[t", function() require("todo-comments").jump_prev() end, { desc = "Previous todo comment" }) + +-- dev plugins -- +vim.cmd.packadd("osc11.nvim") +require('osc11').setup({ + on_dark = function() + require('onedark').setup({ style = 'dark' }) + require('onedark').load() + end, + on_light = function() + require('onedark').setup({ style = 'light' }) + require('onedark').load() + end, +}) + +vim.cmd.packadd("worktrees.nvim") +require('worktrees').setup({ + mappings = { + create = "wtc", + delete = "wtd", + switch = "wts", + }, +}) + +-- winbar -- + +function RenderWinbar() + local path = vim.fs.normalize(vim.fn.expand '%:p' --[[@as string]]) + + if vim.startswith(path, 'diffview') then + return string.format('%%#Winbar#%s', path) + end + + local separator = ' %#WinbarSeparator# ' + + local prefix, prefix_path = '', '' + local folder_icon = '' + + if vim.api.nvim_win_get_width(0) < math.floor(vim.o.columns / 3) then + path = vim.fn.pathshorten(path) + else + local special_dirs = { + DOTFILES = vim.env.XDG_CONFIG_HOME, + GITS = vim.env.HOME .. '/gits', + HOME = vim.env.HOME, + PROJECTS = vim.env.HOME .. '/projects', + } + for dir_name, dir_path in pairs(special_dirs) do + if vim.startswith(path, vim.fs.normalize(dir_path)) and #dir_path > #prefix_path then + prefix, prefix_path, folder_icon = dir_name, dir_path, MiniIcons.get('file', path) + end + end + if prefix ~= '' then + path = path:gsub('^' .. prefix_path, '') + prefix = string.format('%%#WinBarFile#%s %s%s', folder_icon, prefix, separator) + end + end + + path = path:gsub('^/', '') + + vim.api.nvim_set_hl(0, "Winbar", { link = "Normal" }) + vim.api.nvim_set_hl(0, "WinbarSeparator", { link = "Normal" }) + vim.api.nvim_set_hl(0, "WinBarFile", { link = "Normal" }) + + return table.concat { + ' ', + prefix, + table.concat( + vim.iter(vim.split(path, '/')) + :map(function(segment) + return string.format('%%#Winbar#%s', segment) + end) + :totable(), + separator + ), + } +end + +vim.api.nvim_create_autocmd('BufWinEnter', { + group = vim.api.nvim_create_augroup('afonso/winbar', { clear = true }), + desc = 'Attach winbar', + callback = function(args) + if + not vim.api.nvim_win_get_config(0).zindex + and vim.bo[args.buf].buftype == '' + and vim.api.nvim_buf_get_name(args.buf) ~= '' + and not vim.wo[0].diff + then + vim.wo.winbar = "%{%v:lua.RenderWinbar()%}" + end + end, +}) diff --git a/.config/nvim/lua/core/autocmds.lua b/.config/nvim/lua/core/autocmds.lua deleted file mode 100644 index 06e91b7..0000000 --- a/.config/nvim/lua/core/autocmds.lua +++ /dev/null @@ -1,8 +0,0 @@ -vim.api.nvim_create_autocmd("VimLeavePre", { - pattern = "*", - callback = function() - if vim.g.savesession then - vim.api.nvim_command("mks! .session.vim") - end - end -}) diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua deleted file mode 100644 index a532f87..0000000 --- a/.config/nvim/lua/core/keymaps.lua +++ /dev/null @@ -1,31 +0,0 @@ ---Move lines -vim.keymap.set("v", "J", ":m '>+1gv=gv") -vim.keymap.set("v", "K", ":m '<-2gv=gv") ---quickfix keybinds -vim.keymap.set("n", "", "cprevzz") -vim.keymap.set("n", "", "cnextzz") ---buffer keybinds -vim.keymap.set("n", "", "bp") -vim.keymap.set("n", "", "bn") ---jk as escape -vim.keymap.set("i", "jk", "") --- Copy to system clipboard -vim.keymap.set({ 'n', 'x' }, 'gy', '"+y', { desc = 'Copy to system clipboard' }) --- Paste from system clipboard in normal mode -vim.keymap.set('n', 'gp', '"+p', { desc = 'Paste from system clipboard' }) --- Paste from system clipboard in visual mode without overwriting the clipboard -vim.keymap.set('x', 'gp', '"+P', { desc = 'Paste from system clipboard' }) ---Center screen after some motions -vim.keymap.set("n", "", "zz", { desc = "Center cursor after moving down half-page" }) -vim.keymap.set("n", "", "zz", { desc = "Center cursor after moving down half-page" }) -vim.keymap.set("n", "G", "Gzz", { desc = "Center cursor after moving down half-page" }) ---Run lua stuff (ty teej) -vim.keymap.set("n", "x", "source %") -vim.keymap.set("n", "x", ":.lua") -vim.keymap.set("v", "x", ":lua") ---Merge lines in visual mode -vim.keymap.set("v", "", function() - for _ = 1, vim.fn.getpos("'>")[2] - vim.fn.getpos("'<")[2] - 1 do - vim.api.nvim_command("normal! J") - end -end) diff --git a/.config/nvim/lua/core/package_manager.lua b/.config/nvim/lua/core/package_manager.lua deleted file mode 100644 index 8d72c6f..0000000 --- a/.config/nvim/lua/core/package_manager.lua +++ /dev/null @@ -1,27 +0,0 @@ --- 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) - ---Call lazy config here -local lazy = require("lazy") -lazy.setup({ - spec = { - { import = "plugins" } - }, - dev = { - path = vim.fn.stdpath("config") .. "/lua/dev" - } -}) diff --git a/.config/nvim/lua/core/variables.lua b/.config/nvim/lua/core/variables.lua deleted file mode 100644 index 522ed6e..0000000 --- a/.config/nvim/lua/core/variables.lua +++ /dev/null @@ -1,41 +0,0 @@ --- Set the leader key -vim.g.mapleader = " " - --- Appearance -vim.opt.termguicolors = true -- Enable 24-bit colors -vim.opt.number = true -- Show line numbers -vim.opt.relativenumber = true -- Show relative line numbers -vim.opt.wrap = false -- Disable line wrapping -vim.opt.conceallevel = 2 -- Hide Org mode links (assuming you use Org mode) -vim.opt.concealcursor = 'nc' -- Conceal text in normal mode only -vim.opt.signcolumn = "yes" -- Always show the sign column -vim.o.laststatus = 1 -- Always show the status line -vim.o.winborder = nil -- Use default border for floating windows - --- Indentation -vim.opt.tabstop = 4 -- Number of spaces a tab represents -vim.opt.softtabstop = 4 -- Number of spaces a in Insert mode equals -vim.opt.shiftwidth = 4 -- Number of spaces to use for autoindent -vim.opt.expandtab = true -- Use spaces instead of tabs -vim.opt.smartindent = true -- Smart auto-indenting - --- Searching -vim.opt.hlsearch = false -- Disable highlighting of search matches -vim.opt.incsearch = true -- Show partial matches while typing - --- Behavior and Navigation -vim.opt.iskeyword:append("_") -- Add '_' to the list of keyword characters -vim.opt.scrolloff = 10 -- Keep 10 lines above/below cursor when scrolling -vim.opt.sidescrolloff = 10 -vim.opt.smoothscroll = true - --- File Management -vim.opt.undodir = os.getenv("XDG_STATE_HOME") .. "/nvim/undodir" -- Directory for undo files -vim.opt.undofile = true -- Save undo history -vim.opt.backup = true -- Create backup files -vim.opt.backupdir = os.getenv("XDG_STATE_HOME") .. "/nvim/backupdir" -- Directory for backup files -vim.opt.autoread = true -- Automatically reload changed files -vim.opt.swapfile = false -- Disable swap files - --- Formatting -vim.opt.formatoptions:remove("ro") -- Remove 'ro' from formatoptions diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua deleted file mode 100644 index 99e9d56..0000000 --- a/.config/nvim/lua/plugins/cmp.lua +++ /dev/null @@ -1,86 +0,0 @@ -return { - { - 'saghen/blink.cmp', - lazy = false, - dependencies = { - 'rafamadriz/friendly-snippets', - { 'echasnovski/mini.icons', version = '*' }, - }, - version = '*', - opts = { - keymap = { - preset = 'default', - [''] = {}, - [''] = {}, - [''] = { 'scroll_documentation_up', 'fallback' }, - [''] = { 'scroll_documentation_down', 'fallback' }, - }, - appearance = { - use_nvim_cmp_as_default = true, - nerd_font_variant = 'mono' - }, - sources = { - default = { 'lsp', 'path', 'snippets', 'buffer' }, - providers = { - lazydev = { - name = "LazyDev", - module = "lazydev.integrations.blink", - fallbacks = { "lsp" } - }, - }, - }, - signature = { - enabled = true, - window = { - show_documentation = false, - } - }, - cmdline = { - completion = { - menu = { - auto_show = true - } - } - }, - completion = { - accept = { - auto_brackets = { - enabled = true - } - }, - menu = { - border = "single", - winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", - winblend = 0, - draw = { - treesitter = { 'lsp' }, - columns = { { 'kind_icon' }, { 'label' } }, - components = { - kind_icon = { - ellipsis = false, - text = function(ctx) - local kind_icon, _, _ = require('mini.icons').get('lsp', ctx.kind) - return kind_icon - end, - highlight = function(ctx) - local _, hl, _ = require('mini.icons').get('lsp', ctx.kind) - return hl - end, - } - } - } - }, - documentation = { - auto_show = true, - window = { - border = 'single', - max_width = 160, - max_height = 30, - winblend = 0, - winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", - } - }, - }, - }, - }, -} diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua deleted file mode 100644 index cefdf10..0000000 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - { - "sainnhe/gruvbox-material", - event = "VeryLazy", - priority = 1000, - }, - { - "EdenEast/nightfox.nvim", - event = "VeryLazy", - priority = 1000 - }, - { "blazkowolf/gruber-darker.nvim" }, - { "sainnhe/everforest" }, - { - "navarasu/onedark.nvim", - priority = 1000, - } -} diff --git a/.config/nvim/lua/plugins/editing.lua b/.config/nvim/lua/plugins/editing.lua deleted file mode 100644 index f18efe1..0000000 --- a/.config/nvim/lua/plugins/editing.lua +++ /dev/null @@ -1,37 +0,0 @@ -return { - { - "mbbill/undotree", - event = "VeryLazy", - }, - { - 'echasnovski/mini.surround', - version = '*', - opts = {} - }, - { - 'echasnovski/mini.pairs', - version = '*', - config = function() - vim.api.nvim_set_keymap('n', 'S', 'saiw', { silent = true }) - require("mini.pairs").setup({ - mappings = { - -- Prevents the action if the cursor is just before any character or next to a "\". - ["("] = { action = "open", pair = "()", neigh_pattern = "[^\\][%s%)%]%}]" }, - ["["] = { action = "open", pair = "[]", neigh_pattern = "[^\\][%s%)%]%}]" }, - ["{"] = { action = "open", pair = "{}", neigh_pattern = "[^\\][%s%)%]%}]" }, - -- This is default (prevents the action if the cursor is just next to a "\"). - [")"] = { action = "close", pair = "()", neigh_pattern = "[^\\]." }, - ["]"] = { action = "close", pair = "[]", neigh_pattern = "[^\\]." }, - ["}"] = { action = "close", pair = "{}", neigh_pattern = "[^\\]." }, - -- Prevents the action if the cursor is just before or next to any character. - ['"'] = { action = "closeopen", pair = '""', neigh_pattern = "[^%w][^%w]", register = { cr = false } }, - ["'"] = { action = "closeopen", pair = "''", neigh_pattern = "[^%w][^%w]", register = { cr = false } }, - ["`"] = { action = "closeopen", pair = "``", neigh_pattern = "[^%w][^%w]", register = { cr = false } }, - }, - }) - end - }, - - -- Adds S in regex replace and change camelCase to snake_case, etc - "tpope/vim-abolish" -} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua deleted file mode 100644 index 042a73c..0000000 --- a/.config/nvim/lua/plugins/lsp.lua +++ /dev/null @@ -1,271 +0,0 @@ -return { - { - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - { path = "${3rd}/luv/library", words = { "vim%.uv" } } - } - } - }, - { - "smjonas/inc-rename.nvim", - opts = { - save_in_cmdline_history = false, - } - }, - { - "williamboman/mason.nvim", - event = "VeryLazy", - opts = {} - }, - { - "neovim/nvim-lspconfig", - dependencies = { - "saghen/blink.cmp", - "ibhagwan/fzf-lua", - "stevearc/conform.nvim", - }, - event = { "BufReadPost", "BufNewFile" }, - config = function() - local lspconfig = require("lspconfig") - -- Use an on_attach function to only map the following keys - -- after the language server attaches to the current buffer - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - callback = function(ev) - local fzflua = require("fzf-lua") - local conform = require("conform") - - local function jumpWithVirtLineDiags(jumpCount) - pcall(vim.api.nvim_del_augroup_by_name, "jumpWithVirtLineDiags") - - vim.diagnostic.jump { count = jumpCount } - - local initialVirtTextConf = vim.diagnostic.config().virtual_text - vim.diagnostic.config { - virtual_text = false, - virtual_lines = { current_line = true }, - } - - vim.defer_fn(function() - vim.api.nvim_create_autocmd("CursorMoved", { - desc = "User(once): Reset diagnostics virtual lines", - once = true, - group = vim.api.nvim_create_augroup("jumpWithVirtLineDiags", {}), - callback = function() - vim.diagnostic.config { virtual_lines = false, virtual_text = initialVirtTextConf } - end, - }) - end, 1) - end - - local rename_func = function() - return ":IncRename " .. vim.fn.expand("") - end - - local bufopts = { noremap = true, silent = true, buffer = ev.buf } - local bufopts_expr = { expr = true } - vim.keymap.set("n", "e", vim.diagnostic.open_float, bufopts) - vim.keymap.set("n", "q", vim.diagnostic.setloclist, bufopts) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) - vim.keymap.set("n", "gr", fzflua.lsp_references, bufopts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) - vim.keymap.set("n", "gi", fzflua.lsp_implementations, bufopts) - vim.keymap.set("n", "k", vim.lsp.buf.signature_help, bufopts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) - vim.keymap.set("n", "rn", rename_func, bufopts_expr) - vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "ge", function() jumpWithVirtLineDiags(1) end, bufopts) - vim.keymap.set("n", "gE", function() jumpWithVirtLineDiags(-1) end, bufopts) - vim.keymap.set("n", "fo", function() conform.format({ lsp_fallback = true }) end, bufopts) - end, - }) - local capabilities = require('blink.cmp').get_lsp_capabilities(nil, true) - lspconfig["gopls"].setup({ - capabilities = capabilities, - settings = { - gopls = { - ["ui.completion.usePlaceholders"] = true, - ["ui.diagnostic.staticcheck"] = true, - ["ui.inlayhint.hints"] = { - assignVariablesTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - completeUnimported = true, - constantValues = true, - functionTypeParameters = true, - parameterNames = true, - rangeVariableTypes = true, - analyses = { - unusedparams = true, - } - }, - } - } - }) - lspconfig["lua_ls"].setup({ - capabilities = capabilities, - settings = { - Lua = { - hint = { enable = true }, - }, - }, - }) - lspconfig["ltex"].setup({ - capabilities = capabilities, - on_attach = function(_, _) - require("ltex_extra").setup() - end, - settings = { - ltex = { - language = "en-GB", - additionalRules = { - enablePickyRules = true, - languageModel = '~/Downloads/ngrams/', - }, - }, - }, - }) - lspconfig["hls"].setup({ - capabilities = capabilities, - filetypes = { 'haskell', 'lhaskell', 'cabal' }, - }) - vim.lsp.config['clangd'].capabilities = capabilities - vim.lsp.enable('clangd') - - lspconfig["texlab"].setup({ - capabilities = capabilities, - }) - lspconfig["bashls"].setup({ - capabilities = capabilities, - }) - lspconfig["zls"].setup({ - capabilities = capabilities, - }) - lspconfig["pyright"].setup({ - capabilities = capabilities, - }) - vim.lsp.config["tinymist"] = { - capabilities = capabilities, - settings = { - -- exportPdf = "onType", - -- outputPath = "$root/$name", - formatterMode = "typstyle", - fontPaths = { - "./fonts" - } - }, - on_attach = function(client, bufnr) - vim.keymap.set("n", "tp", function() - client:exec_cmd({ - title = "pin", - command = "tinymist.pinMain", - arguments = { vim.api.nvim_buf_get_name(0) }, - }, { bufnr = bufnr }) - end, { desc = "[T]inymist [P]in", noremap = true }) - vim.keymap.set("n", "tu", function() - client:exec_cmd({ - title = "unpin", - command = "tinymist.pinMain", - arguments = { vim.v.null }, - }, { bufnr = bufnr }) - end, { desc = "[T]inymist [U]npin", noremap = true }) - end, - - } - vim.lsp.enable("tinymist") - vim.lsp.config['nil_ls'].capabilities = capabilities - vim.lsp.enable('nil_ls') - end, - }, - { - 'chomosuke/typst-preview.nvim', - ft = 'typst', - version = '1.*', - opts = { - extra_args = {"--font-path=fonts"}, - invert_colors = '{"rest": "auto","image": "never"}' - }, - }, - { - "stevearc/conform.nvim", - event = "VeryLazy", - config = function() - require("conform").setup({ - formatters_by_ft = { - python = { "black" }, - haskell = { "fourmolu" }, - javascript = { "prettierd" }, - markdown = { "mdformat" }, - rust = { "rustfmt" }, - go = { "gofmt" }, - json = { "jq" }, - bash = { "shfmt", "beautysh" }, - zsh = { "beautysh" } - } - }) - end, - }, - { - 'mfussenegger/nvim-lint', - config = function() - local lint = require("lint") - - lint.linters_by_ft = { - go = { "golangcilint" }, - } - - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) - - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) - - vim.keymap.set("n", "li", function() - lint.try_lint() - end, { desc = "Trigger linting for current file" }) - end, - }, - - { - "lervag/vimtex", - filetypes = { "tex" }, - config = function() - if vim.loop.os_uname().sysname == "Darwin" then - vim.g.vimtex_view_method = 'sioyek' - else - vim.g.vimtex_view_method = 'zathura' - end - vim.g.vimtex_quickfix_ignore_filters = { - "warning", - "Warning" - } - vim.g.vimtex_quickfix_open_on_warning = 0 - vim.g.vimtex_quickfix_ignore_filters = { - 'Overfull', - 'Underfull', - } - vim.g.vimtex_compiler_method = 'latexmk' - vim.g.vimtex_compiler_latexmk = { - out_dir = 'build', - options = { - "-verbose", - "-shell-escape", - "-file-line-error", - "-synctex=1", - "-interaction=nonstopmode", - } - } - vim.g.vimtex_view_automatic = 1 - end, - }, - { - "barreiroleo/ltex-extra.nvim", - event = "VeryLazy", - }, -} diff --git a/.config/nvim/lua/plugins/misc.lua b/.config/nvim/lua/plugins/misc.lua deleted file mode 100644 index 8974baa..0000000 --- a/.config/nvim/lua/plugins/misc.lua +++ /dev/null @@ -1,93 +0,0 @@ -return { - { - "folke/todo-comments.nvim", - event = "VeryLazy", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { - vim.keymap.set("n", "]t", function() - require("todo-comments").jump_next() - end, { desc = "Next todo comment" }), - - vim.keymap.set("n", "[t", function() - require("todo-comments").jump_prev() - end, { desc = "Previous todo comment" }) - }, - }, - { - "folke/snacks.nvim", - priority = 1000, - lazy = false, - opts = { - bigfile = { enabled = true }, - notifier = { enabled = true }, - notify = { enabled = true }, - quickfile = { enabled = true }, - statuscolumn = { enabled = true }, - dashboard = { enabled = true }, - input = { enabled = true }, - image = { - doc = { - inline = false, - float = true, - max_width = 10, - max_height = 5, - } - }, - lazygit = { - vim.keymap.set('n', 'lg', function() - Snacks.lazygit.open() - end) - }, - words = { - debounce = 10, - vim.keymap.set('n', 'gn', function() - Snacks.words.jump(1, true) - end) - }, - }, - }, - { - "FabijanZulj/blame.nvim", - event = "VeryLazy", - config = function() - require("blame").setup() - end - }, - "tpope/vim-fugitive", - { - "afonsofrancof/worktrees.nvim", - dev = true, - event = "VeryLazy", - opts = { - mappings = { - create = "wtc", - delete = "wtd", - switch = "wts", - } - } - }, - { - "afonsofrancof/osc11.nvim", - dev = false, - dependencies = { - "navarasu/onedark.nvim", - }, - opts = { - on_dark = function() - vim.g.gruvbox_material_better_performance = 1 - vim.g.gruvbox_material_background = "hard" - vim.g.gruvbox_material_foreground = "original" - vim.g.gruvbox_material_transparent_background = 2 - vim.opt.background = "dark" - vim.cmd('colorscheme gruvbox-material') - end, - on_light = function() - require('onedark').setup { - style = 'light' - } - -- Enable theme - require('onedark').load() - end, - } - } -} diff --git a/.config/nvim/lua/plugins/navigation.lua b/.config/nvim/lua/plugins/navigation.lua deleted file mode 100644 index 4748919..0000000 --- a/.config/nvim/lua/plugins/navigation.lua +++ /dev/null @@ -1,60 +0,0 @@ -return { - { - "ThePrimeagen/harpoon", - event = "VeryLazy", - 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", "", 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 - }, - { - "stevearc/oil.nvim", - config = function() - require("oil").setup({ - float = { - preview_split = "right" - }, - }) - -- Function to open oil.nvim in a vertical split - local function open_oil_split() - -- Calculate the width for the split (20% of the total width) - local width = math.floor(vim.o.columns * 0.2) -- 20% of total width - -- Create a vertical split and set width - vim.cmd("vsplit") -- Create a vertical split - vim.cmd(string.format("vertical resize %d", width)) -- Resize to 20% - -- Open oil in the new split - require("oil").open() -- Use open() to open oil.nvim - end - - -- Key mapping to open oil in a vertical split - vim.api.nvim_set_keymap('n', 'o', ':lua require("oil").open_float()', { noremap = true, silent = true }) - vim.keymap.set('n', 'O', open_oil_split, { noremap = true, silent = true }) - - end - }, - { - 'mrjones2014/smart-splits.nvim', - config = function() - require('smart-splits').setup({}) - --Resize - vim.keymap.set('n', '', require('smart-splits').resize_left) - vim.keymap.set('n', '', require('smart-splits').resize_down) - vim.keymap.set('n', '', require('smart-splits').resize_up) - vim.keymap.set('n', '', require('smart-splits').resize_right) - --Move - vim.keymap.set('n', '', require('smart-splits').move_cursor_left) - vim.keymap.set('n', '', require('smart-splits').move_cursor_down) - vim.keymap.set('n', '', require('smart-splits').move_cursor_up) - vim.keymap.set('n', '', require('smart-splits').move_cursor_right) - end - }, -} diff --git a/.config/nvim/lua/plugins/picker.lua b/.config/nvim/lua/plugins/picker.lua deleted file mode 100644 index 24479bf..0000000 --- a/.config/nvim/lua/plugins/picker.lua +++ /dev/null @@ -1,42 +0,0 @@ -return { - { - "ibhagwan/fzf-lua", - event = "VeryLazy", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - local fzflua = require('fzf-lua') - fzflua.register_ui_select() - fzflua.setup({ - defaults = { - winopts = { - border = "rounded", - width = 0.6, - height = 0.5, - }, - }, - files = { - previewer = false, - winopts = { - width = 0.5, - height = 0.5, - } - }, - grep = { - winopts = { - width = 0.7, - preview = { - layout = "horizontal", - horizontal = "right:40%" - } - }, - } - }) - vim.keymap.set('n', 'ff', fzflua.files, {}) - vim.keymap.set('n', 'fe', fzflua.diagnostics_workspace, {}) - vim.keymap.set('n', 'fg', fzflua.live_grep, {}) - vim.keymap.set('n', 'fb', fzflua.buffers, {}) - vim.keymap.set('n', 'fh', fzflua.help_tags, {}) - vim.keymap.set({'n','v'}, 'fc', fzflua.commands, {}) - end - } -} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index 6001626..0000000 --- a/.config/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,56 +0,0 @@ -return { - - { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPost", "BufNewFile" }, - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects' - }, - config = function() - local treesitter = require("nvim-treesitter.configs") - - require('nvim-treesitter.install').update({ with_sync = true }) - - - local options = { - auto_install = true, - highlight = { - enable = true, - disable = { "latex" }, - use_languagetree = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, - indent = { - enable = true, - }, - } - - treesitter.setup(options) - end - }, - { - 'echasnovski/mini.ai', - event = "VeryLazy", - version = false, - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects' - }, - config = function() - local gen_spec = require('mini.ai').gen_spec - require('mini.ai').setup({ - custom_textobjects = { - F = gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }), - }, - n_lines = 1000 - }) - end - }, -} diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua deleted file mode 100644 index c8de17f..0000000 --- a/.config/nvim/lua/plugins/ui.lua +++ /dev/null @@ -1,42 +0,0 @@ -return { - - { - "folke/noice.nvim", - event = "VeryLazy", - opts = { - cmdline = { - enabled = true, - view = "cmdline", - }, - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - }, - signature = { - enabled = false - } - }, - presets = { - inc_rename = true, - }, - }, - dependencies = { - "MunifTanjim/nui.nvim", - } - }, - { - "OXY2DEV/markview.nvim", - ft = "markdown", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons" - } - }, - { - 'norcalli/nvim-colorizer.lua', - config = function() - require 'colorizer'.setup() - end - }, -} diff --git a/.config/nvim/lua/winbar.lua b/.config/nvim/lua/winbar.lua deleted file mode 100644 index 18060d2..0000000 --- a/.config/nvim/lua/winbar.lua +++ /dev/null @@ -1,81 +0,0 @@ -local M = {} -local icons = require("mini.icons") - ---- Window bar that shows the current file path (in a fancy way). ----@return string -function M.render() - -- Get the path and expand variables. - local path = vim.fs.normalize(vim.fn.expand '%:p' --[[@as string]]) - - -- No special styling for diff views. - if vim.startswith(path, 'diffview') then - return string.format('%%#Winbar#%s', path) - end - - -- Replace slashes by arrows. - local separator = ' %#WinbarSeparator# ' - - local prefix, prefix_path = '', '' - local folder_icon = '' - - -- If the window gets too narrow, shorten the path and drop the prefix. - if vim.api.nvim_win_get_width(0) < math.floor(vim.o.columns / 3) then - path = vim.fn.pathshorten(path) - else - -- For some special folders, add a prefix instead of the full path (making - -- sure to pick the longest prefix). - ---@type table - local special_dirs = { - DOTFILES = vim.env.XDG_CONFIG_HOME, - GITS = vim.env.HOME .. '/gits', - HOME = vim.env.HOME, - PROJECTS = vim.env.HOME .. '/projects', - } - for dir_name, dir_path in pairs(special_dirs) do - if vim.startswith(path, vim.fs.normalize(dir_path)) and #dir_path > #prefix_path then - prefix, prefix_path, folder_icon = dir_name, dir_path, icons.get('file',path) - end - end - if prefix ~= '' then - path = path:gsub('^' .. prefix_path, '') - prefix = string.format('%%#WinBarFile#%s %s%s', folder_icon, prefix, separator) - end - end - - -- Remove leading slash. - path = path:gsub('^/', '') - - vim.api.nvim_set_hl(0, "Winbar", { link = "Normal" }) - vim.api.nvim_set_hl(0, "WinbarSeparator", { link = "Normal" }) - vim.api.nvim_set_hl(0, "WinBarFile", { link = "Normal" }) - - return table.concat { - ' ', - prefix, - table.concat( - vim.iter(vim.split(path, '/')) - :map(function(segment) - return string.format('%%#Winbar#%s', segment) - end) - :totable(), - separator - ), - } -end - -vim.api.nvim_create_autocmd('BufWinEnter', { - group = vim.api.nvim_create_augroup('afonso/winbar', { clear = true }), - desc = 'Attach winbar', - callback = function(args) - if - not vim.api.nvim_win_get_config(0).zindex -- Not a floating window - and vim.bo[args.buf].buftype == '' -- Normal buffer - and vim.api.nvim_buf_get_name(args.buf) ~= '' -- Has a file name - and not vim.wo[0].diff -- Not in diff mode - then - vim.wo.winbar = "%{%v:lua.require'winbar'.render()%}" - end - end, -}) - -return M diff --git a/.config/nvim/nvim-pack-lock.json b/.config/nvim/nvim-pack-lock.json new file mode 100644 index 0000000..b5f1753 --- /dev/null +++ b/.config/nvim/nvim-pack-lock.json @@ -0,0 +1,151 @@ +{ + "plugins": { + "blame.nvim": { + "rev": "179da7aaacce7c52874af636255ede72dd6fe796", + "src": "https://github.com/FabijanZulj/blame.nvim" + }, + "blink.cmp": { + "rev": "451168851e8e2466bc97ee3e026c3dcb9141ce07", + "src": "https://github.com/saghen/blink.cmp", + "version": ">=0.0.0" + }, + "conform.nvim": { + "rev": "086a40dc7ed8242c03be9f47fbcee68699cc2395", + "src": "https://github.com/stevearc/conform.nvim" + }, + "everforest": { + "rev": "b03a03148c8b34c24c96960b93da9c8883d11f54", + "src": "https://github.com/sainnhe/everforest" + }, + "friendly-snippets": { + "rev": "6cd7280adead7f586db6fccbd15d2cac7e2188b9", + "src": "https://github.com/rafamadriz/friendly-snippets" + }, + "fzf-lua": { + "rev": "6e41ba7505f35a6f054ca682b043aa0cea36c2ef", + "src": "https://github.com/ibhagwan/fzf-lua" + }, + "gruvbox-material": { + "rev": "790afe9dd085aa04eccd1da3626c5fa05c620e53", + "src": "https://github.com/sainnhe/gruvbox-material" + }, + "harpoon": { + "rev": "87b1a3506211538f460786c23f98ec63ad9af4e5", + "src": "https://github.com/ThePrimeagen/harpoon", + "version": "'harpoon2'" + }, + "inc-rename.nvim": { + "rev": "0074b551a17338ccdcd299bd86687cc651bcb33d", + "src": "https://github.com/smjonas/inc-rename.nvim" + }, + "lazydev.nvim": { + "rev": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d", + "src": "https://github.com/folke/lazydev.nvim" + }, + "ltex-extra.nvim": { + "rev": "49ea83c231139d98b7c9668c99e7b4591421b056", + "src": "https://github.com/barreiroleo/ltex-extra.nvim" + }, + "mason.nvim": { + "rev": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65", + "src": "https://github.com/williamboman/mason.nvim" + }, + "mini.ai": { + "rev": "4b0a6207341d895b6cfe9bcb1e4d3e8607bfe4f4", + "src": "https://github.com/echasnovski/mini.ai", + "version": "'HEAD'" + }, + "mini.icons": { + "rev": "ff2e4f1d29f659cc2bad0f9256f2f6195c6b2428", + "src": "https://github.com/echasnovski/mini.icons", + "version": ">=0.0.0" + }, + "mini.pairs": { + "rev": "d5a29b6254dad07757832db505ea5aeab9aad43a", + "src": "https://github.com/echasnovski/mini.pairs", + "version": ">=0.0.0" + }, + "mini.surround": { + "rev": "88c52297ed3e69ecf9f8652837888ecc727a28ee", + "src": "https://github.com/echasnovski/mini.surround", + "version": ">=0.0.0" + }, + "nvim-dap": { + "rev": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5", + "src": "https://github.com/mfussenegger/nvim-dap" + }, + "nvim-dap-view": { + "rev": "1b538131335f807ab54baa2bc06b811d5dd75079", + "src": "https://github.com/igorlfs/nvim-dap-view" + }, + "nvim-lint": { + "rev": "606b823a57b027502a9ae00978ebf4f5d5158098", + "src": "https://github.com/mfussenegger/nvim-lint" + }, + "nvim-lspconfig": { + "rev": "dd261ad5266ab5bbec249d21efeceda98ff3e1a6", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "2f5d4c3f3c675962242096bcc8e586d76dd72eb2", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "nvim-treesitter-textobjects": { + "rev": "4e91b5d0394329a229725b021a8ea217099826ef", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" + }, + "nvim-web-devicons": { + "rev": "d7462543c9e366c0d196c7f67a945eaaf5d99414", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "oil.nvim": { + "rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e", + "src": "https://github.com/stevearc/oil.nvim" + }, + "onedark.nvim": { + "rev": "213c23ae45a04797572242568d5d51937181792d", + "src": "https://github.com/navarasu/onedark.nvim" + }, + "plenary.nvim": { + "rev": "b9fd5226c2f76c951fc8ed5923d85e4de065e509", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "smart-splits.nvim": { + "rev": "82d01bb71bc051955654b3af68355f783d872fe0", + "src": "https://github.com/mrjones2014/smart-splits.nvim" + }, + "snacks.nvim": { + "rev": "a049339328e2599ad6e85a69fa034ac501e921b2", + "src": "https://github.com/folke/snacks.nvim" + }, + "tiny-glimmer.nvim": { + "rev": "932e6c2cc4a43ce578f007db1f8f61ad6798f938", + "src": "https://github.com/rachartier/tiny-glimmer.nvim" + }, + "todo-comments.nvim": { + "rev": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668", + "src": "https://github.com/folke/todo-comments.nvim" + }, + "typst-preview.nvim": { + "rev": "e123a7ab64e52d836e00dea9251e85b201f38966", + "src": "https://github.com/chomosuke/typst-preview.nvim", + "version": "1.0.0 - 2.0.0" + }, + "undotree": { + "rev": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d", + "src": "https://github.com/mbbill/undotree" + }, + "vim-abolish": { + "rev": "dcbfe065297d31823561ba787f51056c147aa682", + "src": "https://github.com/tpope/vim-abolish" + }, + "vim-fugitive": { + "rev": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0", + "src": "https://github.com/tpope/vim-fugitive" + }, + "vimtex": { + "rev": "82d2305ff71dfb3bd91602534cc9bb9a195bcb38", + "src": "https://github.com/lervag/vimtex" + } + } +} \ No newline at end of file diff --git a/.config/nvim/pack/local/opt/osc11.nvim b/.config/nvim/pack/local/opt/osc11.nvim new file mode 160000 index 0000000..548380b --- /dev/null +++ b/.config/nvim/pack/local/opt/osc11.nvim @@ -0,0 +1 @@ +Subproject commit 548380b6ef9f45d877215657bca55f5ca2ca4f1a diff --git a/.config/nvim/pack/local/opt/worktrees.nvim b/.config/nvim/pack/local/opt/worktrees.nvim new file mode 160000 index 0000000..8707262 --- /dev/null +++ b/.config/nvim/pack/local/opt/worktrees.nvim @@ -0,0 +1 @@ +Subproject commit 87072627075bf5fbd4f7c82ad34d84ecbe0546e9 diff --git a/.gitmodules b/.gitmodules index 7340c18..97a8a7c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -38,3 +38,9 @@ path = .config/xmobar/xmobar-git url = https://codeberg.org/xmobar/xmobar branch = master +[submodule ".config/nvim/pack/local/opt/worktrees.nvim"] + path = .config/nvim/pack/local/opt/worktrees.nvim + url = git@github.com:afonsofrancof/worktrees.nvim +[submodule ".config/nvim/pack/local/opt/osc11.nvim"] + path = .config/nvim/pack/local/opt/osc11.nvim + url = git@github.com:afonsofrancof/osc11.nvim