commit 6136857a055718bdf4eec4ff8f6372a7e58a4296 Author: ignuki Date: Thu Feb 13 18:25:31 2025 +0100 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..ca2162a --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,2 @@ +require("ink") +require("config.lazy") diff --git a/nvim/.config/nvim/lua/config/lazy.lua b/nvim/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..96934cd --- /dev/null +++ b/nvim/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,41 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "dracula" } }, + -- automatically check for plugin updates + checker = { + enabled = false, + concurrency = nil, + notify = false, + frequency = 3600, + check_pinned = false, + }, +}) diff --git a/nvim/.config/nvim/lua/ink/init.lua b/nvim/.config/nvim/lua/ink/init.lua new file mode 100644 index 0000000..a8cd911 --- /dev/null +++ b/nvim/.config/nvim/lua/ink/init.lua @@ -0,0 +1,100 @@ +require("ink.remap") + +vim.opt.hlsearch = false -- do not highlight matches +vim.wo.number = true +vim.opt.relativenumber = true +vim.opt.mouse = "a" +vim.opt.clipboard = "unnamedplus" +vim.opt.breakindent = true -- Enable break indent +vim.opt.undofile = true -- Save undo history +vim.opt.ignorecase = true -- ignore case in searches by default +vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered +vim.w.signcolumn = "yes" -- Keep signcolumn on by default +vim.opt.updatetime = 250 -- Decrease update time +vim.opt.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds) +vim.opt.backup = false -- creates a backup file +vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited +vim.opt.completeopt = "menuone,noselect" -- Set completeopt to have a better completion experience +vim.opt.termguicolors = true -- set termguicolors to enable highlight groups +vim.opt.whichwrap = "bs<>[]hl" -- which "horizontal" keys are allowed to travel to prev/next line +vim.opt.wrap = false -- display lines as one long line +vim.opt.linebreak = true -- companion to wrap don't split words +vim.opt.scrolloff = 4 -- minimal number of screen lines to keep above and below the cursor +vim.opt.sidescrolloff = 8 -- minimal number of screen columns either side of cursor if wrap is `false` +vim.opt.numberwidth = 2 -- set number column width to 2 {default 4} +vim.opt.shiftwidth = 4 -- Number of spaces inserted when indenting +vim.opt.tabstop = 4 -- A TAB character looks like 4 spaces +vim.opt.softtabstop = 4 -- Number of spaces inserted instead of a TAB character +vim.opt.expandtab = true -- Pressing the TAB key will insert spaces instead of a TAB character +vim.opt.cursorline = true +vim.opt.splitbelow = true -- open new vertical split bottom +vim.opt.splitright = true -- open new horizontal splits right +vim.opt.swapfile = false -- creates a swapfile +vim.opt.smartindent = true -- make indenting smarter again +vim.opt.showtabline = 2 -- always show tabs +vim.opt.backspace = "indent,eol,start" -- allow backspace on +vim.opt.pumheight = 10 -- pop up menu height +vim.wo.conceallevel = 0 -- so that `` is visible in markdown files +vim.opt.encoding = "utf-8" -- the encoding written to a file +vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages +vim.opt.autoindent = true + +vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages +vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches +vim.opt.formatoptions:remove({ "c", "r", "o" }) -- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting in insert mode, or hitting 'o' or 'O' in normal mode. +vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins from neovim in case vim still in use + +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" +vim.opt.foldtext = "" +vim.opt.foldlevel = 99 +vim.opt.foldlevelstart = 99 +vim.opt.foldnestmax = 6 +vim.opt.incsearch = true -- search as characters are entered + +vim.opt.tags:append({ ".git/tags", "tags" }) + +vim.opt.shell = "/bin/zsh" + +-- remove trailing whitespace +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = { "*" }, + callback = function() + local save_cursor = vim.fn.getpos(".") + pcall(function() + vim.cmd([[%s/\s\+$//e]]) + end) + vim.fn.setpos(".", save_cursor) + end, +}) + +-- local uv = vim.uv +local uv = vim.loop + +vim.api.nvim_create_autocmd({ "VimEnter", "VimLeave" }, { + callback = function() + if vim.env.TMUX_PLUGIN_MANAGER_PATH then + uv.spawn(vim.env.TMUX_PLUGIN_MANAGER_PATH .. "/tmux-window-name/scripts/rename_session_windows.py", {}) + end + end, +}) +-- +-- Filetypes to enable spellcheck +local spell_types = { "text", "plaintex", "typst", "gitcommit", "markdown" } + +-- Set global spell option to false initially to disable it for all file types +vim.opt.spell = false + +-- Create an augroup for spellcheck to group related autocommands +vim.api.nvim_create_augroup("Spellcheck", { clear = true }) + +-- Create an autocommand to enable spellcheck for specified file types +vim.api.nvim_create_autocmd({ "FileType" }, { + group = "Spellcheck", -- Grouping the command for easier management + pattern = spell_types, -- Only apply to these file types + callback = function() + vim.opt_local.spell = true -- Enable spellcheck for these file types + end, + desc = "Enable spellcheck for defined filetypes", -- Description for clarity +}) + diff --git a/nvim/.config/nvim/lua/ink/remap.lua b/nvim/.config/nvim/lua/ink/remap.lua new file mode 100644 index 0000000..3437d6e --- /dev/null +++ b/nvim/.config/nvim/lua/ink/remap.lua @@ -0,0 +1,58 @@ +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = " " +-- (mode, key, command) +vim.keymap.set({ "n", "v" }, "", "", { silent = true }) +-- vim.keymap.set("n", "pv", vim.cmd.Ex, { desc = "Open current directory" }) + +local function map(mode, lhs, rhs, opts) + local options = { noremap = true, silent = true } + if opts then + if opts.desc then + opts.desc = "keymaps.lua: " .. opts.desc + end + options = vim.tbl_extend("force", options, opts) + end + vim.keymap.set(mode, lhs, rhs, options) +end + +map("n", "sn", "noautocmd w ", { desc = "Save without formatting" }) -- save without autoformat + +map("n", "x", '"_x', { desc = "Remove character under cursor without clipboard" }) + +map("n", "n", "nzzzv", { desc = "Find next occurence of search" }) +map("n", "N", "Nzzzv", { desc = "Find previous occurence of search" }) + +map("n", "", ":bnext", { desc = "Switch to next buffer" }) +map("n", "", ":bprev", { desc = "Switch to previous buffer" }) +map("n", "x", ":bdelete!", { desc = "Close buffer" }) +map("n", "b", " enew ", { desc = "Open new buffer" }) + +map("n", "v", "v", { desc = "Split vertical" }) +map("n", "h", "s", { desc = "Split horizontal" }) +map("n", "se", "=", { desc = "Reset split sizes" }) +map("n", "xs", ":close", { desc = "Close split" }) + +map("v", "<", "", ">gv", { desc = "Indent right" }) +map("v", "p", '"_dP', { desc = "Paste without yanking underlying text" }) + +map("n", "gl", "`.", { desc = "Jump to the last change in the file" }) + +-- map('n', '', 'za', { desc = 'Toggle cursor fold' }) +-- map('n', '', 'zm', { desc = 'Toggle all folds at cursor' }) +-- map('n', '', 'zM', { desc = 'Close all open folds' }) +-- map('n', '', 'zr', { desc = 'Open all folds' }) +-- map('n', '', 'zR', { desc = 'Open all folds' }) + +map("n", "", "", { desc = "Move to split upwards" }) +map("n", "", "", { desc = "Move to split upwards" }) +map("n", "", "", { desc = "Move to split left" }) +map("n", "", "", { desc = "Move to split right" }) + +map("n", "", "", { desc = "Move screen up one line" }) +map("n", "", "", { desc = "Move screen down one line" }) +map("v", "", "", { desc = "Move screen up one line" }) +map("v", "", "", { desc = "Move screen down one line" }) diff --git a/nvim/.config/nvim/lua/plugins/basic.lua b/nvim/.config/nvim/lua/plugins/basic.lua new file mode 100644 index 0000000..fc61b82 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/basic.lua @@ -0,0 +1,47 @@ +return { + { -- highlight and search TODO commends + "folke/todo-comments.nvim", + cmd = { "TodoTrouble", "TodoTelescope" }, + opts = {}, + -- stylua: ignore + keys = { + { "]t", function() require("todo-comments").jump_next() end, desc = "Next Todo Comment" }, + { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous Todo Comment" }, + { "xt", "Trouble todo toggle", desc = "Todo (Trouble)" }, + { "xT", "Trouble todo toggle filter = {tag = {TODO,FIX,FIXME}}", desc = "Todo/Fix/Fixme (Trouble)" }, + { "st", "TodoTelescope", desc = "Todo" }, + { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, + }, + }, + -- keymap helper + { "folke/which-key.nvim", opts = {} }, + { -- undo tree + "mbbill/undotree", + opts = {}, + keys = { + { "u", vim.cmd.UndotreeToggle, desc = "Toggle undo tree" }, + }, + }, + { -- minimal and fast autopairs + "echasnovski/mini.pairs", + event = "VeryLazy", + opts = { + modes = { insert = true, command = true, terminal = false }, + -- skip autopair when next character is one of these + skip_next = [=[[%w%%%'%[%"%.%`%$]]=], + -- skip autopair when the cursor is inside these treesitter nodes + skip_ts = { "string" }, + -- skip autopair when next character is closing pair + -- and there are more closing pairs than opening pairs + skip_unbalanced = true, + -- better deal with markdown code blocks + markdown = true, + }, + }, + { -- fugitive + "tpope/vim-fugitive", + keys = { + { "gs", vim.cmd.Git, desc = "Fugitive git command" }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..c317e54 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -0,0 +1,258 @@ +return { + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }, + }, + { + "saghen/blink.cmp", + -- optional: provides snippets for the snippet source + dependencies = { + "rafamadriz/friendly-snippets", + "Kaiser-Yang/blink-cmp-dictionary", + "moyiz/blink-emoji.nvim", + "mikavilpas/blink-ripgrep.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + }, + + -- use a release tag to download pre-built binaries + version = "*", + -- 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', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' for mappings similar to built-in completion + -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate) + -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept + -- See the full "keymap" documentation for information on defining your own keymap. + keymap = { + preset = "enter", + }, + + completion = { + list = { + selection = { + preselect = function(ctx) + return ctx.mode ~= "cmdline" + end, + }, + }, + + menu = { + -- nvim-cmp style menu + draw = { + columns = { + { "label", "label_description", gap = 1 }, + { "kind_icon", "kind" }, + }, + }, + }, + + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + + ghost_text = { enabled = false }, + }, + + appearance = { + -- Sets the fallback highlight groups to nvim-cmp's highlight groups + -- Useful for when your theme doesn't support blink.cmp + -- Will be removed in a future release + use_nvim_cmp_as_default = true, + -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + --default = { 'lsp', 'path', 'snippets', 'buffer', 'ctags' }, + default = { "lazydev", "lsp", "path", "snippets", "buffer", "ripgrep", "emoji" }, + providers = { + lazydev = { + name = "LazyDev", + module = "lazydev.integrations.blink", + -- make lazydev completions top priority (see `:h blink.cmp`) + score_offset = 100, + }, + 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, + }, + ripgrep = { + module = "blink-ripgrep", + name = "Ripgrep", + -- the options below are optional, some default values are shown + ---@module "blink-ripgrep" + ---@type blink-ripgrep.Options + opts = { + -- For many options, see `rg --help` for an exact description of + -- the values that ripgrep expects. + + -- the minimum length of the current word to start searching + -- (if the word is shorter than this, the search will not start) + prefix_min_len = 3, + + -- The number of lines to show around each match in the preview + -- (documentation) window. For example, 5 means to show 5 lines + -- before, then the match, and another 5 lines after the match. + context_size = 5, + + -- The maximum file size of a file that ripgrep should include in + -- its search. Useful when your project contains large files that + -- might cause performance issues. + -- Examples: + -- "1024" (bytes by default), "200K", "1M", "1G", which will + -- exclude files larger than that size. + max_filesize = "1M", + + -- Specifies how to find the root of the project where the ripgrep + -- search will start from. Accepts the same options as the marker + -- given to `:h vim.fs.root()` which offers many possibilities for + -- configuration. If none can be found, defaults to Neovim's cwd. + -- + -- Examples: + -- - ".git" (default) + -- - { ".git", "package.json", ".root" } + project_root_marker = { ".git", ".terraform", "requirements.txt", "lazy-lock.json" }, + + -- Enable fallback to neovim cwd if project_root_marker is not + -- found. Default: `true`, which means to use the cwd. + project_root_fallback = true, + + -- The casing to use for the search in a format that ripgrep + -- accepts. Defaults to "--ignore-case". See `rg --help` for all the + -- available options ripgrep supports, but you can try + -- "--case-sensitive" or "--smart-case". + search_casing = "--ignore-case", + + -- (advanced) Any additional options you want to give to ripgrep. + -- See `rg -h` for a list of all available options. Might be + -- helpful in adjusting performance in specific situations. + -- If you have an idea for a default, please open an issue! + -- + -- Not everything will work (obviously). + additional_rg_options = {}, + + -- When a result is found for a file whose filetype does not have a + -- treesitter parser installed, fall back to regex based highlighting + -- that is bundled in Neovim. + fallback_to_regex_highlighting = true, + + -- Absolute root paths where the rg command will not be executed. + -- Usually you want to exclude paths using gitignore files or + -- ripgrep specific ignore files, but this can be used to only + -- ignore the paths in blink-ripgrep.nvim, maintaining the ability + -- to use ripgrep for those paths on the command line. If you need + -- to find out where the searches are executed, enable `debug` and + -- look at `:messages`. + ignore_paths = {}, + + -- Any additional paths to search in, in addition to the project + -- root. This can be useful if you want to include dictionary files + -- (/usr/share/dict/words), framework documentation, or any other + -- reference material that is not available within the project + -- root. + additional_paths = {}, + + -- Features that are not yet stable and might change in the future. + -- You can enable these to try them out beforehand, but be aware + -- that they might change. Nothing is enabled by default. + future_features = { + -- Keymaps to toggle features on/off. This can be used to alter + -- the behavior of the plugin without restarting Neovim. Nothing + -- is enabled by default. + toggles = { + -- The keymap to toggle the plugin on and off from blink + -- completion results. Example: "tg" + on_off = "tg", + }, + }, + + -- Show debug information in `:messages` that can help in + -- diagnosing issues with the plugin. + debug = false, + }, + -- (optional) customize how the results are displayed. Many options + -- are available - make sure your lua LSP is set up so you get + -- autocompletion help + transform_items = function(_, items) + for _, item in ipairs(items) do + -- example: append a description to easily distinguish rg results + item.labelDetails = { + description = "(rg)", + } + end + return items + end, + }, + }, + }, + }, + opts_extend = { "sources.default" }, + }, + { + "neovim/nvim-lspconfig", + dependencies = { + "saghen/blink.cmp", + -- "netmute/ctags-lsp.nvim" + }, + + -- example using `opts` for defining servers + opts = { + servers = { + -- brew install rust-analyzer + rust_analyzer = { + settings = { + ["rust-analyzer"] = {}, + }, + }, + -- lua_ls = { + -- settings = { + -- Lua = { + -- diagnostics = { + -- globals = { "vim" }, + -- undefined_global = false, -- remove this from diag! + -- missing_parameters = false, -- missing fields :) + -- }, + -- }, + -- }, + -- }, + -- ctags_lsp = {}, + }, + }, + config = function(_, opts) + local lspconfig = require("lspconfig") + --- brew install netmute/tap/ctags-lsp + -- require("lspconfig").ctags_lsp.setup({}) + + for server, config in pairs(opts.servers) do + -- passing config.capabilities to blink.cmp merges with the capabilities in your + -- `opts[server].capabilities, if you've defined it + config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities) + lspconfig[server].setup(config) + end + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/file_explorer.lua b/nvim/.config/nvim/lua/plugins/file_explorer.lua new file mode 100644 index 0000000..0d1acd0 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/file_explorer.lua @@ -0,0 +1,21 @@ +return { + { + "stevearc/oil.nvim", + ---@module 'oil' + ---@type oil.SetupOpts + opts = { + default_file_explorer = true, + view_options = { + show_hidden = true, + }, + }, + -- Optional dependencies + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + keys = { + { "pv", "Oil", desc = "Open current directory" }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/formatting.lua b/nvim/.config/nvim/lua/plugins/formatting.lua new file mode 100644 index 0000000..60196ea --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/formatting.lua @@ -0,0 +1,104 @@ +return { + -- heuristic indent + { "tpope/vim-sleuth" }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + --@diagnostic disable-next-line: missing-fields + configs.setup({ + ensure_installed = { + "bash", + "c", + "cmake", + "dockerfile", + "gitignore", + "go", + "java", + "json", + "lua", + "make", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "rust", + "terraform", + "vim", + "vimdoc", + "yaml", + }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (or "all") + ignore_install = { "javascript" }, + + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", + -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + disable = {}, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + -- 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, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + indent = { + enable = false, + disable = {}, + }, + }) + end, + }, + { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local conform = require("conform") + conform.setup({ + formatters_by_ft = { + -- brew install stylua + lua = { "stylua" }, + rust = { "rustfmt" }, + }, + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 500, + }, + }) + vim.keymap.set({ "n", "v" }, "mp", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 500, + }) + end, { desc = "Format file or range (in visual mode)" }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/linting.lua b/nvim/.config/nvim/lua/plugins/linting.lua new file mode 100644 index 0000000..179e7bf --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/linting.lua @@ -0,0 +1,23 @@ +return { + { + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require("lint") + lint.linters_by_ft = { + lua = { "luacheck" }, + } + 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", "l", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..acc58e2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,137 @@ +return { + { -- file finder + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + event = "VimEnter", + dependencies = { + "nvim-lua/plenary.nvim", + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + cond = function() + return vim.fn.executable("make") == 1 + end, + }, + "nvim-telescope/telescope-ui-select.nvim", + + -- Useful for getting pretty icons, but requires a Nerd Font. + "nvim-tree/nvim-web-devicons", + }, + config = function() + local actions = require("telescope.actions") + local builtin = require("telescope.builtin") + + require("telescope").setup({ + defaults = { + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.select_default, -- open file + }, + n = { + ["q"] = actions.close, + }, + }, + }, + pickers = { + find_files = { + file_ignore_patterns = { + "node_modules", + "target", + ".terraform", + ".git", + ".venv", + }, + hidden = true, + }, + buffers = { + initial_mode = "normal", + sort_lastused = true, + -- sort_mru = true, + mappings = { + n = { + ["d"] = actions.delete_buffer, + ["l"] = actions.select_default, + }, + }, + }, + }, + live_grep = { + file_ignore_patterns = { + "node_modules", + "target", + ".terraform", + ".git", + ".venv", + }, + additional_args = function(_) + return { "--hidden" } + end, + }, + path_display = { + filename_first = { + reverse_directories = true, + }, + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown(), + }, + }, + git_files = { + previewer = false, + }, + }) + + -- Enable telescope fzf native, if installed + pcall(require("telescope").load_extension, "fzf") + pcall(require("telescope").load_extension, "ui-select") + + vim.keymap.set("n", "pf", builtin.find_files, { desc = "Telescope find files" }) + vim.keymap.set("n", "", builtin.git_files, { desc = "Telescope find git files" }) + vim.keymap.set("n", "ps", function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) + end, { desc = "Telescope grep" }) + vim.keymap.set("n", "gc", builtin.git_commits, { desc = "Search [G]it [C]ommits" }) + vim.keymap.set( + "n", + "gcf", + builtin.git_bcommits, + { desc = "Search [G]it [C]ommits for current [F]ile" } + ) + vim.keymap.set("n", "gb", builtin.git_branches, { desc = "Search [G]it [B]ranches" }) + vim.keymap.set("n", "gs", builtin.git_status, { desc = "Search [G]it [S]tatus (diff view)" }) + + vim.keymap.set("n", "?", builtin.oldfiles, { desc = "[?] Find recently opened files" }) + vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch existing [B]uffers" }) + + vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) + vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) + vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) + vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]resume" }) + vim.keymap.set("n", "s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set("n", "sds", function() + builtin.lsp_document_symbols({ + symbols = { "Class", "Function", "Method", "Constructor", "Interface", "Module", "Property" }, + }) + end, { desc = "[S]each LSP document [S]ymbols" }) + vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) + vim.keymap.set("n", "s/", function() + builtin.live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files", + }) + end, { desc = "[S]earch [/] in Open Files" }) + vim.keymap.set("n", "/", function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + previewer = false, + })) + end, { desc = "[/] Fuzzily search in current buffer" }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/tmux.lua b/nvim/.config/nvim/lua/plugins/tmux.lua new file mode 100644 index 0000000..6633be3 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/tmux.lua @@ -0,0 +1,19 @@ +return { + { -- integration with tmux config + "alexghergh/nvim-tmux-navigation", + config = function() + local nvim_tmux_nav = require("nvim-tmux-navigation") + + nvim_tmux_nav.setup({ + disable_when_zoomed = true, -- defaults to false + }) + + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateLeft) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateDown) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateUp) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateRight) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateLastActive) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateNext) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua new file mode 100644 index 0000000..253cb73 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -0,0 +1,104 @@ +return { + { -- colorscheme + "Mofiqul/dracula.nvim", + lazy = false, + name = "dracula", + priority = 1000, + config = function() + local dracula = require("dracula") + dracula.setup({ + colors = { + visual = "#5a5e77", + }, + -- show the '~' characters after the end of buffers + show_end_of_buffer = true, -- default false + -- use transparent background + transparent_bg = false, -- default false + -- set custom lualine background color + lualine_bg_color = "#44475a", -- default nil + -- set italic comment + italic_comment = true, -- default false + -- overrides the default highlights with table see `:h synIDattr` + overrides = { + CursorLine = { bg = "#3e4153" }, + CursorLineNr = { fg = "DarkOrange", bold = true }, + }, + }) + vim.cmd [[colorscheme dracula-soft]] + end + }, + -- highlight color hex codes + { + "brenoprata10/nvim-highlight-colors", + opts = {}, + config = function() + local highlight = require("nvim-highlight-colors") + highlight.setup() + end + }, + { --statusline + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + lazy = false, + opts = { + options = { + section_separators = "", + component_separators = "", + theme = "dracula-nvim" + }, + -- extensions = { "neo-tree", "lazy", "fzf" }, + extensions = { "fugitive", "lazy" }, + }, + }, + { -- git symbols on sidebar + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + signs_staged = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + }, + }, + { -- cosmetic indent lines + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + opts = { + indent = { + char = "▏", + }, + scope = { + show_start = false, + show_end = false, + show_exact_scope = false, + }, + exclude = { + filetypes = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", + }, + }, + }, + }, + { -- colorful mode indicators + 'mvllow/modes.nvim', + tag = 'v0.2.1', + config = function() + require('modes').setup() + end + }, +} diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..2e27c56 --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,88 @@ +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' + +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' + +set -g @continuum-boot 'on' + +set -g @continuum-boot-options 'iterm,fullscreen' + +set -g @plugin 'dracula/tmux' + +# set -Fg 'status-format[1]' '#{status-format[0]}' +# set -g 'status-format[0]' '' +# set -g status 2 + +set -g @dracula-plugins "git weather time battery" +set -g @dracula-show-fahrenheit false +set -g @dracula-fixed-location "Madrid" +set -g @dracula-show-powerline false +set -g @dracula-transparent-powerline-bg true +set -g @dracula-military-time true +set -g @dracula-day-month true + +set -g @plugin 'ofirgall/tmux-window-name' +set -g @tmux_window_name_substitute_sets "[('.+bash', 'bash')]" +set -g @tmux_window_name_shells "['bash', 'fish', 'sh', 'zsh']" +set -g @tmux_window_dir_programs "['nvim', 'vim', 'vi', 'git']" +set -g @tmux_window_name_use_tilde "True" +set -g @tmux_window_name_max_name_len "100" +set-option -g default-shell $SHELL +set -g default-command "$SHELL -i" + +# Other examples: +# set -g @plugin 'github_username/plugin_name' +# set -g @plugin 'github_username/plugin_name#branch' +# set -g @plugin 'git@github.com:user/plugin' +# set -g @plugin 'git@bitbucket.com:user/plugin' +bind r source-file ~/.tmux.conf \; display "Reloaded!" # Reload with ctrl-r +set -sg escape-time 1 # quicker responses + +set -g base-index 1 # Numbering of windows +setw -g pane-base-index 1 # Numbering of Panes + +set -g mouse on + +bind-key -n C-t new-window +bind-key -n C-S-T new-window -c '#{pane_current_path}' + +bind-key -n C-S-Down next-window +bind-key -n C-S-Up previous-window +bind-key -n C-S-Left swap-window -t -1\; select-window -t -1 +bind-key -n C-S-Right swap-window -t +1\; select-window -t +1 + +# Smart pane switching with awareness of Vim splits. +# See: https://github.com/christoomey/vim-tmux-navigator + +setw -g mode-keys vi + +# decide whether we're in a Vim process +#is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ +# | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" + +is_vim="~/is_vim.sh '#{pane_tty}'" + +bind-key -n 'S-Left' if-shell "$is_vim" 'send-keys S-Left' 'select-pane -L' +bind-key -n 'S-Down' if-shell "$is_vim" 'send-keys S-Down' 'select-pane -D' +bind-key -n 'S-Up' if-shell "$is_vim" 'send-keys S-Up' 'select-pane -U' +bind-key -n 'S-Right' if-shell "$is_vim" 'send-keys S-Right' 'select-pane -R' + +tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' + +if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" +if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + +bind-key -n 'C-Space' if-shell "$is_vim" 'send-keys C-Space' 'select-pane -t:.+' + +bind-key -T copy-mode-vi 'S-Left' select-pane -L +bind-key -T copy-mode-vi 'S-Down' select-pane -D +bind-key -T copy-mode-vi 'S-Up' select-pane -U +bind-key -T copy-mode-vi 'S-Right' select-pane -R +bind-key -T copy-mode-vi 'C-\' select-pane -l +bind-key -T copy-mode-vi 'C-Space' select-pane -t:.+ + +run '~/.tmux/plugins/tpm/tpm' diff --git a/zsh/.zsh_aliases b/zsh/.zsh_aliases new file mode 100644 index 0000000..fea09d7 --- /dev/null +++ b/zsh/.zsh_aliases @@ -0,0 +1,24 @@ +#!/bin/bash + +alias tree='tree -CF --du -h' + +# alias tf="aws-vault exec feedzai-main -d 8h -- terraform" +# alias tfi="aws-vault exec feedzai-main -d 8h -- terraform init" +# alias tfp="aws-vault exec feedzai-main -d 8h -- terraform plan -lock=false" +# alias tfa="aws-vault exec feedzai-main -d 8h -- terraform apply" +# alias tfu="aws-vault exec feedzai-main -d 8h -- terraform get -update" +# +# alias tg="aws-vault exec feedzai-main -d 8h -- terragrunt" +# alias tgi="aws-vault exec feedzai-main -d 8h -- terragrunt init" +# alias tgp="aws-vault exec feedzai-main -d 8h -- terragrunt plan -lock=false" +# alias tga="aws-vault exec feedzai-main -d 8h -- terragrunt apply" +# alias tgu="aws-vault exec feedzai-main -d 8h -- terragrunt get -update" +# alias tgg="aws-vault exec feedzai-main -d 8h -- terragrunt graph-dependencies" + +alias idot='dot -Tsvg -Goverlap=scale -Grankdir=RL -Gbgcolor="#282a36" -Ncolor="#f8f8f2" -Ecolor="#f8f8f2" -Nfontcolor="#f8f8f2" -Gfontname="PragmataPro Mono Liga Regular" -Gfontsize=13 -Nfontname="PragmataPro" -Nfontsize=13 -Nshape=box -Earrowhead=normal' +alias icat="kitty +kitten icat" + +alias curltime="curl -w \"@$HOME/.curl-format.txt\" -o /dev/null -s " + +alias vi=nvim +alias vim=nvim diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..a60a257 --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,3 @@ +. "$HOME/.cargo/env" + +if [ -f ~/.zshrc ]; then . ~/.zshrc; fi diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..6ed44d6 --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,65 @@ +export HISTFILE=~/.zsh_history +export HISTSIZE=5000000 +export SAVEHIST=$HISTSIZE + +setopt INC_APPEND_HISTORY +setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format. +setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history. +setopt HIST_FIND_NO_DUPS # Do not display a previously found event. +setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate. +setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again. +setopt HIST_IGNORE_SPACE # Do not record an event starting with a space. +setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. +setopt SHARE_HISTORY # Share history between all sessions. + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# enable color support of ls and also add handy aliases +export CLICOLOR=1 +zstyle ':completion:*:default' list-colors '' +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +SSH_ENV="$HOME/.ssh/agent-environment" + +function start_ssh_agent { + echo "Initialising new SSH agent..." + /usr/bin/ssh-agent | sed 's/^echo/#echo/' >"${SSH_ENV}" + echo succeeded + chmod 600 "${SSH_ENV}" + . "${SSH_ENV}" >/dev/null + /usr/bin/ssh-add +} + +# Source SSH settings, if applicable + +#if [ -f "${SSH_ENV}" ]; then +# SSH_AGENT_PID="$(echo $(($(cat /proc/sys/kernel/pid_max) + 1)))" +# . "${SSH_ENV}" > /dev/null +# ps -ef | grep ${SSH_AGENT_PID} | grep 'ssh-agent$' > /dev/null || { +# start_ssh_agent; +# } +#else +# start_ssh_agent; +#fi + +if [ -f ~/.zsh_aliases ]; then + . ~/.zsh_aliases +fi + +export PATH=~/.local/bin:$PATH + +function set_win_title(){ + echo -ne "\033]0; $(basename "$PWD") \007" +} +starship_precmd_user_func="set_win_title" + +eval "$(starship init zsh)" + +eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"