From a5dab140d0f3837ed4f70fdf1bb30fec72e7800e Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Sun, 28 Jan 2024 15:18:27 +0100 Subject: [PATCH] Initial Commit --- flake.lock | 288 +++++++++++++++++++++++++ flake.nix | 64 ++++++ neovim-empty/default.nix | 15 ++ neovim-ide/after/README.md | 8 + neovim-ide/after/ftplugin/nix.lua | 4 + neovim-ide/default.nix | 27 +++ neovim-ide/ftplugin/go.lua | 11 + neovim-ide/ftplugin/python.lua | 1 + neovim-ide/ftplugin/rust.lua | 49 +++++ neovim-ide/lua/user/lsp.lua | 23 ++ neovim-ide/plugin/00-settings.lua | 89 ++++++++ neovim-ide/plugin/augroups.lua | 81 +++++++ neovim-ide/plugin/cmp.lua | 111 ++++++++++ neovim-ide/plugin/colorscheme.lua | 75 +++++++ neovim-ide/plugin/dap.lua | 98 +++++++++ neovim-ide/plugin/general.lua | 14 ++ neovim-ide/plugin/git.lua | 1 + neovim-ide/plugin/indent-blankline.lua | 37 ++++ neovim-ide/plugin/lsp.lua | 78 +++++++ neovim-ide/plugin/lualine.lua | 70 ++++++ neovim-ide/plugin/mini.lua | 38 ++++ neovim-ide/plugin/neo-tree.lua | 102 +++++++++ neovim-ide/plugin/neorg.lua | 50 +++++ neovim-ide/plugin/noice.lua | 23 ++ neovim-ide/plugin/telescope.lua | 102 +++++++++ neovim-ide/plugin/treesitter.lua | 42 ++++ neovim-ide/plugin/trouble.lua | 18 ++ neovim-ide/plugin/which-key.lua | 9 + neovim-ide/plugins.nix | 97 +++++++++ nix/lib/default.nix | 5 + nix/lib/mkNeovim.nix | 2 + nix/lib/mkNeovimConfig.nix | 61 ++++++ nix/lib/mkNeovimPlugin.nix | 6 + nix/overlay.nix | 8 + 34 files changed, 1707 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 neovim-empty/default.nix create mode 100644 neovim-ide/after/README.md create mode 100644 neovim-ide/after/ftplugin/nix.lua create mode 100644 neovim-ide/default.nix create mode 100644 neovim-ide/ftplugin/go.lua create mode 100644 neovim-ide/ftplugin/python.lua create mode 100644 neovim-ide/ftplugin/rust.lua create mode 100644 neovim-ide/lua/user/lsp.lua create mode 100644 neovim-ide/plugin/00-settings.lua create mode 100644 neovim-ide/plugin/augroups.lua create mode 100644 neovim-ide/plugin/cmp.lua create mode 100644 neovim-ide/plugin/colorscheme.lua create mode 100644 neovim-ide/plugin/dap.lua create mode 100644 neovim-ide/plugin/general.lua create mode 100644 neovim-ide/plugin/git.lua create mode 100644 neovim-ide/plugin/indent-blankline.lua create mode 100644 neovim-ide/plugin/lsp.lua create mode 100644 neovim-ide/plugin/lualine.lua create mode 100644 neovim-ide/plugin/mini.lua create mode 100644 neovim-ide/plugin/neo-tree.lua create mode 100644 neovim-ide/plugin/neorg.lua create mode 100644 neovim-ide/plugin/noice.lua create mode 100644 neovim-ide/plugin/telescope.lua create mode 100644 neovim-ide/plugin/treesitter.lua create mode 100644 neovim-ide/plugin/trouble.lua create mode 100644 neovim-ide/plugin/which-key.lua create mode 100644 neovim-ide/plugins.nix create mode 100644 nix/lib/default.nix create mode 100644 nix/lib/mkNeovim.nix create mode 100644 nix/lib/mkNeovimConfig.nix create mode 100644 nix/lib/mkNeovimPlugin.nix create mode 100644 nix/overlay.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..387fab1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,288 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704982712, + "narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "07f6395285469419cf9d078f59b5b49993198c00", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gopher-nvim": { + "flake": false, + "locked": { + "lastModified": 1696856053, + "narHash": "sha256-8arSYelWObRnzNQ1F4wh/U44USy5aQFIGA9Aa7p9XXM=", + "owner": "olexsmir", + "repo": "gopher.nvim", + "rev": "ac27f4b6794c872140fb205313d79ab166892fe9", + "type": "github" + }, + "original": { + "owner": "olexsmir", + "repo": "gopher.nvim", + "type": "github" + } + }, + "hercules-ci-effects": { + "inputs": { + "flake-parts": "flake-parts_2", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704029560, + "narHash": "sha256-a4Iu7x1OP+uSYpqadOu8VCPY+MPF3+f6KIi+MAxlgyw=", + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "rev": "d5cbf433a6ae9cae05400189a8dbc6412a03ba16", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1706134977, + "narHash": "sha256-KwNb1Li3K6vuVwZ77tFjZ89AWBo7AiCs9t0Cens4BsM=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "6359d40f6ec0b72a38e02b333f343c3d4929ec10", + "type": "github" + }, + "original": { + "id": "home-manager", + "type": "indirect" + } + }, + "neovim-flake": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "dir": "contrib", + "lastModified": 1706140641, + "narHash": "sha256-H1qHhkf7sF7yrG2rb9Ks1Y4EtLY3cXGp16KCGveJWY4=", + "owner": "neovim", + "repo": "neovim", + "rev": "4e59422e1d4950a3042bad41a7b81c8db4f8b648", + "type": "github" + }, + "original": { + "dir": "contrib", + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-nightly-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "hercules-ci-effects": "hercules-ci-effects", + "neovim-flake": "neovim-flake", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1706141075, + "narHash": "sha256-o66/XFTXmcJSpEcO508V5r765HtgT8qtr+H4LRIB9BY=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "1da2e054a16309d7d7f7669438c8b9a5ef1b4642", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705677747, + "narHash": "sha256-eyM3okYtMgYDgmYukoUzrmuoY4xl4FUujnsv/P6I/zI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bbe7d8f876fbbe7c959c90ba2ae2852220573261", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706006310, + "narHash": "sha256-nDPz0fj0IFcDhSTlXBU2aixcnGs2Jm4Zcuoj0QtmiXQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b43bb235efeab5324c5e486882ef46749188eee2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1705856552, + "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "gopher-nvim": "gopher-nvim", + "home-manager": "home-manager", + "neovim-nightly-overlay": "neovim-nightly-overlay", + "nixpkgs": "nixpkgs_3" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..31846bf --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + neovim-nightly-overlay = { + url = "github:nix-community/neovim-nightly-overlay"; + }; + + # Neovim Plugins + gopher-nvim = { + url = "github:olexsmir/gopher.nvim"; + flake = false; + }; + }; + + outputs = inputs@{ self, nixpkgs, flake-utils, home-manager, ... }: + let + inherit (self) outputs; + nixpkgsConfig = { + config.allowUnfree = false; + }; + neovim-overlay = import ./nix/overlay.nix { inherit inputs; }; + overlays = [ + neovim-overlay + inputs.neovim-nightly-overlay.overlays.default + ]; + localLib = { + mkPkgs = system: + import nixpkgs { + inherit system overlays; + inherit (nixpkgsConfig) config; + }; + }; + in + { + overlays.default = neovim-overlay; + } // + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = localLib.mkPkgs system; + in + { + formatter = pkgs.alejandra; + packages = with pkgs; rec { + nvim-nightly = neovim-nightly; + nvim-ide = neovim-ide; + default = nvim-ide; + }; + devShells = { + default = pkgs.mkShell { + name = "neovim"; + buildInputs = with pkgs; [ + lua-language-server + stylua + luajitPackages.luacheck + ]; + }; + }; + } + ); +} diff --git a/neovim-empty/default.nix b/neovim-empty/default.nix new file mode 100644 index 0000000..c319845 --- /dev/null +++ b/neovim-empty/default.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: +with pkgs.lib; let + runtimepath = ../../neovim-empty; + nvimLib = pkgs.callPackage ../lib { }; + inherit (nvimLib) mkNeovim mkNeovimConfig; + + plugins = []; + + extraPackages = []; + + config = mkNeovimConfig { + inherit extraPackages plugins runtimepath; + }; +in +mkNeovim config diff --git a/neovim-ide/after/README.md b/neovim-ide/after/README.md new file mode 100644 index 0000000..a4b4ff2 --- /dev/null +++ b/neovim-ide/after/README.md @@ -0,0 +1,8 @@ +## `after` directory + +Scripts put in + +- `after/plugin` will be sourced *after* init.lua + or any other scripts are sourced during startup. +- `after/ftplugin` will be sourced when opening a + filetype, *after* any other `ftplugin` scripts are sourced. diff --git a/neovim-ide/after/ftplugin/nix.lua b/neovim-ide/after/ftplugin/nix.lua new file mode 100644 index 0000000..09bcfc9 --- /dev/null +++ b/neovim-ide/after/ftplugin/nix.lua @@ -0,0 +1,4 @@ +local indent_size = 2 +vim.opt.shiftwidth = indent_size +vim.opt.tabstop = indent_size +vim.opt.softtabstop = indent_size diff --git a/neovim-ide/default.nix b/neovim-ide/default.nix new file mode 100644 index 0000000..b6083d9 --- /dev/null +++ b/neovim-ide/default.nix @@ -0,0 +1,27 @@ +{ inputs, pkgs, ... }: +with +pkgs.lib; let + runtimepath = ./.; + plugins = pkgs.callPackage ./plugins.nix { inherit inputs; }; + nvimLib = pkgs.callPackage ../nix/lib { }; + inherit (nvimLib) mkNeovim mkNeovimConfig; + + extraPackages = with pkgs; [ + ripgrep + fd + nixd + rnix-lsp + statix + alejandra + nodePackages.bash-language-server + taplo + jq + shellcheck + ]; + + + config = mkNeovimConfig { + inherit extraPackages plugins runtimepath; + }; +in +mkNeovim config diff --git a/neovim-ide/ftplugin/go.lua b/neovim-ide/ftplugin/go.lua new file mode 100644 index 0000000..4c4f966 --- /dev/null +++ b/neovim-ide/ftplugin/go.lua @@ -0,0 +1,11 @@ +require("gopher").setup({ + commands = { + go = "go", + gomodifytags = "gomodifytags", + gotests = "gotests", -- also you can set custom command path + impl = "impl", + iferr = "iferr", + dlv = "dlv", + }, +}) +require("gopher.dap").setup() diff --git a/neovim-ide/ftplugin/python.lua b/neovim-ide/ftplugin/python.lua new file mode 100644 index 0000000..92489f8 --- /dev/null +++ b/neovim-ide/ftplugin/python.lua @@ -0,0 +1 @@ +require("dap-python").setup() diff --git a/neovim-ide/ftplugin/rust.lua b/neovim-ide/ftplugin/rust.lua new file mode 100644 index 0000000..e484186 --- /dev/null +++ b/neovim-ide/ftplugin/rust.lua @@ -0,0 +1,49 @@ +local crates = require("crates") +require("which-key").register { + ["C"] = { name = "Crate", _ = "which_key_ignore" }, +} + +vim.g.rustaceanvim = { + server = { + settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + check = { command = "clippy" }, + }, + }, + }, +} + +crates.setup { + null_ls = { + enabled = false, + name = "Crates", + }, +} + +local opts = function(opts) + return vim.tbl_deep_extend("force", { silent = true }, opts) +end + +vim.keymap.set("n", "Ct", crates.toggle, opts({ desc = "Crate toggle" })) +vim.keymap.set("n", "Cr", crates.reload, opts({ desc = "Crate reload" })) + +vim.keymap.set("n", "Cv", crates.show_versions_popup, opts({ desc = "Show version popup" })) +vim.keymap.set("n", "Cf", crates.show_features_popup, opts({ desc = "Show features popup" })) +vim.keymap.set("n", "Cd", crates.show_dependencies_popup, opts({ desc = "Show dependencies popup" })) + +vim.keymap.set("n", "Cu", crates.update_crate, opts({ desc = "Update crate" })) +vim.keymap.set("v", "Cu", crates.update_crates, opts({ desc = "Update Crates" })) +vim.keymap.set("n", "Cp", crates.update_all_crates, opts({desc = "Update all crates" })) +vim.keymap.set("n", "CU", crates.upgrade_crate, opts({ desc = "Upgrade crate" })) +vim.keymap.set("v", "CU", crates.upgrade_crates, opts({ desc = "Upgrade crate" })) +vim.keymap.set("n", "CP", crates.upgrade_all_crates, opts({ desc = "Upgrade all crates" })) + +vim.keymap.set("n", "Cx", crates.expand_plain_crate_to_inline_table, + opts({ desc = "Expand plain crate into inline table" })) +vim.keymap.set("n", "CX", crates.extract_crate_into_table, opts({ desc = "Extract crate into table" })) + +vim.keymap.set("n", "CH", crates.open_homepage, opts({ desc = "Open homepage" })) +vim.keymap.set("n", "CR", crates.open_repository, opts({ desc = "Open repository" })) +vim.keymap.set("n", "CD", crates.open_documentation, opts({ desc = "Open documentation" })) +vim.keymap.set("n", "CC", crates.open_crates_io, opts({ desc = "Open crates.io" })) diff --git a/neovim-ide/lua/user/lsp.lua b/neovim-ide/lua/user/lsp.lua new file mode 100644 index 0000000..a28847e --- /dev/null +++ b/neovim-ide/lua/user/lsp.lua @@ -0,0 +1,23 @@ +---@mod user.lsp +--- +---@brief [[ +---LSP related functions +---@brief ]] + +local M = {} + +---Gets a 'ClientCapabilities' object, describing the LSP client capabilities +---Extends the object with capabilities provided by plugins. +---@return lsp.ClientCapabilities +function M.make_client_capabilities() + local capabilities = vim.lsp.protocol.make_client_capabilities() + -- Add com_nvim_lsp capabilities + local cmp_lsp = require("cmp_nvim_lsp") + local cmp_lsp_capabilities = cmp_lsp.default_capabilities() + capabilities = vim.tbl_deep_extend("keep", capabilities, cmp_lsp_capabilities) + -- Add any additional plugin capabilities here. + -- Make sure to follow the instructions provided in the plugin's docs. + return capabilities +end + +return M diff --git a/neovim-ide/plugin/00-settings.lua b/neovim-ide/plugin/00-settings.lua new file mode 100644 index 0000000..004cdbb --- /dev/null +++ b/neovim-ide/plugin/00-settings.lua @@ -0,0 +1,89 @@ +local indent_size = 4 + +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.opt.termguicolors = true + +vim.opt.whichwrap:append("b,s,<,>,[,],h,l") +vim.opt.backspace = "indent,eol,start" + +vim.opt.autoindent = true +vim.opt.expandtab = true +vim.opt.smarttab = true +vim.opt.smartindent = true +vim.opt.shiftwidth = indent_size +vim.opt.tabstop = indent_size +vim.opt.softtabstop = indent_size + +vim.opt.hlsearch = true +vim.opt.incsearch = true +vim.opt.ignorecase = true +vim.opt.smartcase = true + +vim.opt.scrolloff = 8 +vim.opt.splitbelow = true +vim.opt.splitright = true + +vim.opt.startofline = false + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.visualbell = true +vim.opt.errorbells = false + +vim.opt.textwidth = 80 +vim.opt.colorcolumn = { 80 } + +vim.opt.cursorline = true + +vim.opt.undodir = vim.fn.stdpath("state") .. "/undo" +vim.opt.undofile = true +vim.opt.backupdir = vim.fn.stdpath("state") .. "/backup" +vim.opt.backup = true + +vim.opt.mouse = "a" +vim.opt.selectmode = "mouse" +vim.opt.mousemoveevent = true + +vim.opt.timeoutlen = 300 + +vim.opt.list = true +vim.opt.listchars:append("eol:↴") +vim.opt.listchars:append("space:.") + +vim.opt.spell = true +vim.opt.spelllang = { "de", "en_us" } +vim.opt.helplang = "de" + +vim.opt.laststatus = 3 + +vim.opt.conceallevel = 0 +vim.opt.concealcursor = "nc" + +vim.opt.foldlevel = 0 + +vim.keymap.set({ "n", "v" }, "", "", { silent = true }) + +vim.keymap.set("t", "", "") + +vim.keymap.set("n", "q:", "", { noremap = true }) + +vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +vim.keymap.set("n", "", ":m -2", {}) +vim.keymap.set("n", "", ":m +1", {}) +vim.keymap.set("v", "", ":m '<-2gv=gv", {}) +vim.keymap.set("v", "", ":m '>+1gv=gv", {}) +--[[ +" Bubble single lines +nmap ddkP +nmap ddp +" Bubble multiple lines +vmap xkP`[V`] +vmap xp`[V`] +]]-- + +vim.g.inlay_hints_visible = true diff --git a/neovim-ide/plugin/augroups.lua b/neovim-ide/plugin/augroups.lua new file mode 100644 index 0000000..0e08399 --- /dev/null +++ b/neovim-ide/plugin/augroups.lua @@ -0,0 +1,81 @@ +-- Yank Hightlight +local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) +vim.api.nvim_create_autocmd("TextYankPost", { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = "*", +}) + +-- Text Conceal +local conceal_group = vim.api.nvim_create_augroup("conceal", { clear = true }) +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + group = conceal_group, + pattern = { "*.md", "*.json", "*.norg" }, + callback = function() + vim.opt.conceallevel = 3 + end, +}) + +vim.api.nvim_create_autocmd({ "BufLeave", "BufWinLeave" }, { + group = conceal_group, + pattern = { "*.md", "*.json", "*.norg" }, + callback = function() + vim.opt.conceallevel = 0 + end, +}) + +-- Remember cursor position +vim.api.nvim_create_autocmd("BufRead", { + callback = function(opts) + vim.api.nvim_create_autocmd("BufWinEnter", { + once = true, + buffer = opts.buf, + callback = function() + local ft = vim.bo[opts.buf].filetype + local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1] + if + not (ft:match("commit") and ft:match("rebase")) + and last_known_line > 1 + and last_known_line <= vim.api.nvim_buf_line_count(opts.buf) + then + vim.api.nvim_feedkeys([[g`"]], "nx", false) + end + end, + }) + end, +}) + +-- LSP Attach +local lsp_attach_augroup = vim.api.nvim_create_augroup("lsp_attach", { clear = true }) +vim.api.nvim_create_autocmd("LspAttach", { + group = lsp_attach_augroup, + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + if not client then + return + end + + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(ev.buf, true) + end + + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Goto Declaration" }) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Goto Defninition" }) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Goto Implementation" }) + vim.keymap.set("n", "gtd", vim.lsp.buf.type_definition, { desc = "Show Type Definition" }) + vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "Goto References" }) + vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover" }) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "Rename" }) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, { desc = "Code action" }) + vim.keymap.set("n", "fm", function() + vim.lsp.buf.format { async = true } + end, { desc = "Format Code" }) + end, +}) diff --git a/neovim-ide/plugin/cmp.lua b/neovim-ide/plugin/cmp.lua new file mode 100644 index 0000000..5d6e9dc --- /dev/null +++ b/neovim-ide/plugin/cmp.lua @@ -0,0 +1,111 @@ +local cmp = require("cmp") +local lspkind = require("lspkind") +local luasnip = require("luasnip") + +local has_words_before = function() + local unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +local base_mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete {}, + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm { select = true }, +} +local buffer_mapping = vim.tbl_deep_extend("force", base_mapping, { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- that way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), +}) + +local config = { + formatting = { + format = lspkind.cmp_format { + mode = "symbol_text", + maxwidth = 50, + ellipsis_char = "…", + menu = { + nvim_lsp = "[LSP]", + nvim_lsp_signature_help = "[LSP]", + nvim_lsp_document_symbol = "[LSP]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + nvim_lua = "[Lua]", + emoji = "[Emoji]", + }, + }, + }, + completion = { + completeopt = "menu,menuone", + }, + window = { + completion = { + side_padding = 0, + scrollbar = false, + }, + documentation = {}, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert(buffer_mapping), + sources = cmp.config.sources { + { name = "luasnip" }, + { name = "nvim_lsp" }, + { name = "neorg" }, + { name = "buffer" }, + { name = "fuzzy_path" }, + }, +} + +local cmdline_config = { + mapping = cmp.mapping.preset.cmdline(base_mapping), + completion = { + completeopt = "menu,menuone,noselect", + }, + sources = cmp.config.sources({ + { name = "fuzzy_path" }, + }, { + { name = "cmdline" }, + }), +} +local search_config = { + mapping = cmp.mapping.preset.cmdline(base_mapping), + completion = { + completeopt = "menu,menuone,noselect", + }, + sources = { + { name = "buffer" }, + }, +} + +cmp.setup(config) +cmp.setup.cmdline("/", search_config) +cmp.setup.cmdline("?", search_config) +cmp.setup.cmdline(":", cmdline_config) diff --git a/neovim-ide/plugin/colorscheme.lua b/neovim-ide/plugin/colorscheme.lua new file mode 100644 index 0000000..548b5f6 --- /dev/null +++ b/neovim-ide/plugin/colorscheme.lua @@ -0,0 +1,75 @@ +require("catppuccin").setup { + flavour = "mocha", -- latte, frappe, macchiato, mocha + background = { -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = false, -- disables setting the background color. + show_end_of_buffer = false, -- shows the '~' characters after the end of buffers + term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) + dim_inactive = { + enabled = false, -- dims the background color of inactive window + shade = "dark", + percentage = 0.05, -- percentage of the shade to apply to the inactive window + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + no_underline = false, -- Force no underline + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { "italic" }, -- Change the style of comments + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + integrations = { + cmp = true, + gitsigns = true, + neotree = true, + treesitter = true, + --notify = false, + mini = true, + fidget = true, + noice = true, + indent_blankline = { + enabled = true, + }, + mason = false, + rainbow_delimiters = true, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, + custom_highlights = function(colors) + local bg1 = colors.mantle + local bg2 = colors.crust + local fg0 = colors.text + local green = colors.green + local red = colors.red + return { + TelescopePreviewBorder = { fg = bg1, bg = bg1 }, + TelescopePreviewNormal = { bg = bg1 }, + TelescopePreviewTitle = { fg = fg0, bg = green }, + TelescopePromptBorder = { fg = bg2, bg = bg2 }, + TelescopePromptNormal = { fg = fg0, bg = bg2 }, + TelescopePromptPrefix = { fg = red, bg = bg2 }, + TelescopePromptTitle = { fg = fg0, bg = red }, + TelescopeResultsBorder = { fg = bg1, bg = bg1 }, + TelescopeResultsNormal = { bg = bg1 }, + TelescopeResultsTitle = { fg = bg1, bg = bg1 }, + TelescopeSelection = { bg = bg2, fg = colors.text }, + TelescopeResultsDiffAdd = { fg = fg0 }, + TelescopeResultsDiffChange = { fg = fg0 }, + TelescopeResultsDiffDelete = { fg = fg0 }, + NotifyBackground = { bg = bg2 }, + } + end, +} + +vim.cmd.colorscheme("catppuccin-mocha") diff --git a/neovim-ide/plugin/dap.lua b/neovim-ide/plugin/dap.lua new file mode 100644 index 0000000..eb0bcf8 --- /dev/null +++ b/neovim-ide/plugin/dap.lua @@ -0,0 +1,98 @@ +local dapui = require("dapui") +local dap = require("dap") +require("nvim-dap-virtual-text").setup {} +dapui.setup() + +require("dap.ext.vscode").load_launchjs(nil, { rt_lldb = { "rust" } }) + +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end +dap.listeners.before.launch.dapui_config = function() + dapui.open() +end +dap.listeners.after.event_initialized.dapui_config = function() + dapui.open() +end +dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() +end +dap.listeners.before.event_exited.dapui_config = function() + dapui.close() +end + +vim.keymap.set("n", "db", vim.cmd.DapToggleBreakpoint, { desc = "Toggle Debug Breakpoint" }) +vim.keymap.set("n", "dc", vim.cmd.DapContinue, { desc = "Debug Continue" }) +vim.keymap.set("n", "dC", function() dap.run_last() end, { desc = "Debug Continue" }) +vim.keymap.set("n", "dn", vim.cmd.DapStepOver, { desc = "Debug Step Over" }) +vim.keymap.set("n", "di", vim.cmd.DapStepIn, { desc = "Debug Step In" }) +vim.keymap.set("n", "do", vim.cmd.DapStepOut, { desc = "Debug Step Out" }) +vim.keymap.set("n", "dt", vim.cmd.DapTerminate, { desc = "Debug Terminate" }) +vim.keymap.set("n", "dr", vim.cmd.DapToggleRepl, { desc = "Debug Toggle REPL" }) +vim.keymap.set("n", "du", function() + require("dapui").toggle {} +end, { desc = "Toggle Debug UI" }) + +vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "", numhl = "DapBreakpoint" }) +vim.fn.sign_define( + "DapBreakpointCondition", + { text = "ﳁ", texthl = "DapBreakpoint", linehl = "", numhl = "DapBreakpoint" } +) +vim.fn.sign_define( + "DapBreakpointRejected", + { text = "", texthl = "DapBreakpoint", linehl = "", numhl = "DapBreakpoint" } +) +vim.fn.sign_define("DapLogPoint", { text = "", texthl = "DapLogPoint", linehl = "", numhl = "DapLogPoint" }) +vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", linehl = "", numhl = "DapStopped" }) + +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "-i", "dap" }, +} + +dap.adapters.lldb = { + type = "executable", + command = "lldb-vscode", -- adjust as needed, must be absolute path + name = "lldb", +} + +local lldb_config = { + name = "Launch", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", +} + +local lldb_attach_config = { + name = "Attach to process", + type = "lldb", -- Adjust this to match your adapter name (`dap.adapters.`) + request = "attach", + pid = require("dap.utils").pick_process, + args = {}, +} + +local rust_config = vim.tbl_deep_extend("force", lldb_config, { + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file") + end, +}) + +dap.configurations.c = { + lldb_config, + lldb_attach_config +} + +dap.configurations.rust = { rust_config, lldb_attach_config } + +dap.adapters.delve = { + type = 'server', + port = '${port}', + executable = { + command = 'dlv', + args = {'dap', '-l', '127.0.0.1:${port}'}, + } +} diff --git a/neovim-ide/plugin/general.lua b/neovim-ide/plugin/general.lua new file mode 100644 index 0000000..2fc866c --- /dev/null +++ b/neovim-ide/plugin/general.lua @@ -0,0 +1,14 @@ +require("gitsigns").setup() +require("nvim-web-devicons").setup() +require("colorizer").setup {} +require("todo-comments").setup() +require("tmux").setup { + resize = { + enable_default_keybindings = true, + resize_step_x = 4, + resize_step_y = 2, + }, + navigation = { + enable_default_keybindings = true, + }, +} diff --git a/neovim-ide/plugin/git.lua b/neovim-ide/plugin/git.lua new file mode 100644 index 0000000..e883ec8 --- /dev/null +++ b/neovim-ide/plugin/git.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gg", ":LazyGit", { silent = true }) diff --git a/neovim-ide/plugin/indent-blankline.lua b/neovim-ide/plugin/indent-blankline.lua new file mode 100644 index 0000000..cc3ba13 --- /dev/null +++ b/neovim-ide/plugin/indent-blankline.lua @@ -0,0 +1,37 @@ +local colors = require("catppuccin.palettes.mocha") +local highlight = { + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", +} +local hooks = require("ibl.hooks") +-- create the highlight groups in the highlight setup hook, so they are reset +-- every time the colorscheme changes +hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, "RainbowRed", { fg = colors.red }) + vim.api.nvim_set_hl(0, "RainbowYellow", { fg = colors.yellow }) + vim.api.nvim_set_hl(0, "RainbowBlue", { fg = colors.blue }) + vim.api.nvim_set_hl(0, "RainbowOrange", { fg = colors.peach }) + vim.api.nvim_set_hl(0, "RainbowGreen", { fg = colors.green }) + vim.api.nvim_set_hl(0, "RainbowViolet", { fg = colors.mauve }) + vim.api.nvim_set_hl(0, "RainbowCyan", { fg = colors.teal }) +end) + +vim.g.rainbow_delimiters = { highlight = highlight } + +require("ibl").setup { + scope = { + highlight = highlight, + }, + indent = { + highlight = highlight, + char = "▎", + tab_char = "▍", + }, +} + +hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) diff --git a/neovim-ide/plugin/lsp.lua b/neovim-ide/plugin/lsp.lua new file mode 100644 index 0000000..2987c67 --- /dev/null +++ b/neovim-ide/plugin/lsp.lua @@ -0,0 +1,78 @@ +local lspconfig = require("lspconfig") +local null_ls = require("null-ls") +local cmp_lsp = require("cmp_nvim_lsp") +require("neodev").setup() +require("luasnip.loaders.from_vscode").lazy_load() + +local capabilities = vim.lsp.protocol.make_client_capabilities() +-- Add com_nvim_lsp capabilities +local cmp_lsp_capabilities = cmp_lsp.default_capabilities() +capabilities = vim.tbl_deep_extend("keep", capabilities, cmp_lsp_capabilities) + + +vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError" }) +vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) +vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) +vim.fn.sign_define("DiagnosticSignHint", { text = "󰌵", texthl = "DiagnosticSignHint" }) +-- +-- Diagnostic keymaps +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) +vim.keymap.set("n", "xd", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) +vim.keymap.set("n", "xl", vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) + +null_ls.setup { + sources = { + null_ls.builtins.code_actions.shellcheck, + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.completion.spell, + null_ls.builtins.diagnostics.eslint, + null_ls.builtins.diagnostics.ruff, + null_ls.builtins.diagnostics.static, + null_ls.builtins.diagnostics.commitlint, + null_ls.builtins.formatting.beautysh, + null_ls.builtins.formatting.jq, + null_ls.builtins.formatting.ruff, + null_ls.builtins.formatting.stylua, + }, +} + +local servers = { + ["lua_ls"] = {}, + ["tsserver"] = {}, + ["gopls"] = { + settings = { + gopls = { + gofumpt = true, + staticcheck = true, + completeUnimported = true, + usePlaceholders = true, + analyses = { + unusedparams = true, + }, + }, + }, + }, + ["emmet_ls"] = {}, + ["html"] = {}, + ["pyright"] = {}, + ["ruff_lsp"] = {}, + --["nil_ls"] = {}, + ["nixd"] = {}, + ["rnix"] = {}, + ["bashls"] = {}, + ["taplo"] = {}, + ["sqlls"] = {}, + ["clangd"] = {}, + ["postgres_lsp"] = {}, +} + +for k, v in pairs(servers) do + lspconfig[k].setup(vim.tbl_deep_extend("force", { + capabilities = capabilities, + diagnostic = { + virtual_text = true, + severity_sort = true, + }, + }, v)) +end diff --git a/neovim-ide/plugin/lualine.lua b/neovim-ide/plugin/lualine.lua new file mode 100644 index 0000000..779be21 --- /dev/null +++ b/neovim-ide/plugin/lualine.lua @@ -0,0 +1,70 @@ +local colors = require("catppuccin.palettes").get_palette "mocha" + +require("lualine").setup { + sections = { + lualine_a = { "", { "mode" } }, + lualine_b = { + { "branch" }, + { "diff" }, + }, + lualine_c = { + { "filetype", icon_only = true }, + { "filename" }, + { "diagnostics" }, + { + "lsp_progress", + display_components = { "lsp_client_name", { "title", "percentage", "message" } }, + colors = { + percentage = colors.blue, + title = colors.blue, + message = colors.blue, + spinner = colors.blue, + lsp_client_name = colors.teal, + use = true, + }, + }, + }, + lualine_x = {}, + lualine_y = { + { "encoding" }, + { "fileformat" }, + }, + lualine_z = { + { "progress" }, + }, + }, + winbar = { + lualine_x = { + { "filename", path = 1 }, + { "filetype", icon_only = true }, + }, + }, + inactive_winbar = { + lualine_x = { + { "diagnostics" }, + { "filename", path = 1 }, + { "filetype", icon_only = true }, + }, + }, + extensions = { "fugitive", "lazy", "man", "neo-tree", "nvim-dap-ui", "quickfix" }, + options = { + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = { + "help", + "lazy", + "neo-tree", + "dapui_stacks", + "dapui_watches", + "dapui_breakpoints", + "dapui_scopes", + "dapui_console", + "dap-repl", + "fugitive", + }, + }, + theme = "catppuccin", + }, +} diff --git a/neovim-ide/plugin/mini.lua b/neovim-ide/plugin/mini.lua new file mode 100644 index 0000000..c3c8a69 --- /dev/null +++ b/neovim-ide/plugin/mini.lua @@ -0,0 +1,38 @@ +--[[ +require("mini.move").setup { + mappings = { + -- Move visual selection in Visual mode. Defaults are Alt (Meta) + hjkl. + left = "", + right = "", + down = "", + up = "", + + -- Move current line in Normal mode + line_left = "", + line_right = "", + line_down = "", + line_up = "", + }, +} +require("mini.pairs").setup() +]]-- +require("mini.comment").setup() +require("mini.cursorword").setup() +require("mini.surround").setup { + custom_surroundings = { + ["("] = { output = { left = "( ", right = " )" } }, + ["["] = { output = { left = "[ ", right = " ]" } }, + ["{"] = { output = { left = "{ ", right = " }" } }, + ["<"] = { output = { left = "< ", right = " >" } }, + }, + mappings = { + add = "ys", + delete = "ds", + find = "fs", + find_left = "Fs", + highlight = "", + replace = "cs", + update_n_lines = "", + }, + search_method = "cover_or_next", +} diff --git a/neovim-ide/plugin/neo-tree.lua b/neovim-ide/plugin/neo-tree.lua new file mode 100644 index 0000000..c0f82e6 --- /dev/null +++ b/neovim-ide/plugin/neo-tree.lua @@ -0,0 +1,102 @@ +local neotree = require("neo-tree") +local dap = require("dap") + +dap.listeners.before.attach.dapui_config = function() + require("neo-tree.command").execute { action = "close" } +end +dap.listeners.before.launch.dapui_config = function() + require("neo-tree.command").execute { action = "close" } +end + +neotree.setup { + enable_git_status = true, + enable_diagnostics = true, + source_selector = { + winbar = true, + statusline = false, + sources = { + { source = "filesystem", display_name = " 󰉓 Files" }, + { source = "git_status", display_name = " 󰊢 Git" }, + }, + }, + filesystem = { + hijack_netrw_behavior = "open_default", + use_libuv_file_watcher = true, + follow_current_file = { + enabled = true, + }, + }, + default_component_configs = { + icon = { + folder_closed = "", + folder_open = "", + folder_empty = "", + folder_empty_open = "", + }, + git_status = { + symbols = { + -- Change type + added = "✚", -- or "✚", but this is redundant info if you use git_status_colors on the name + modified = "", -- or "", but this is redundant info if you use git_status_colors on the name + deleted = "✖", -- this can only be used in the git_status source + -- Status type + untracked = "", + ignored = "", + staged = "", + conflict = "", + renamed = "󰁕", + unstaged = "󰄱", + }, + }, + diagnostics = { + symbols = { + hint = "󰌵", + info = "", + warn = "", + error = "", + }, + highlights = { + hint = "DiagnosticSignHint", + info = "DiagnosticSignInfo", + warn = "DiagnosticSignWarn", + error = "DiagnosticSignError", + }, + }, + }, + document_symbols = { + kinds = { + File = { icon = "󰈙", hl = "Tag" }, + Namespace = { icon = "󰌗", hl = "Include" }, + Package = { icon = "󰏖", hl = "Label" }, + Class = { icon = "󰌗", hl = "Include" }, + Property = { icon = "󰆧", hl = "@property" }, + Enum = { icon = "󰒻", hl = "@number" }, + Function = { icon = "󰊕", hl = "Function" }, + String = { icon = "󰀬", hl = "String" }, + Number = { icon = "󰎠", hl = "Number" }, + Array = { icon = "󰅪", hl = "Type" }, + Object = { icon = "󰅩", hl = "Type" }, + Key = { icon = "󰌋", hl = "" }, + Struct = { icon = "󰌗", hl = "Type" }, + Operator = { icon = "󰆕", hl = "Operator" }, + TypeParameter = { icon = "󰊄", hl = "Type" }, + StaticMethod = { icon = "󰠄 ", hl = "Function" }, + }, + }, + hover = { + enabled = true, + delay = 200, + }, + event_handlers = { + { + event = "file_opened", + handler = function(_) + require("neo-tree.command").execute { action = "close" } + end, + }, + }, +} + +vim.keymap.set("n", "e", function() + vim.cmd.Neotree("toggle") +end, { desc = "Toggle File explorer" }) diff --git a/neovim-ide/plugin/neorg.lua b/neovim-ide/plugin/neorg.lua new file mode 100644 index 0000000..471e82b --- /dev/null +++ b/neovim-ide/plugin/neorg.lua @@ -0,0 +1,50 @@ +local neorg = require("neorg") + +local workspace_root = vim.env.NORG_ROOT +if workspace_root == nil then + workspace_root = "~/Sync/norg" +end + +neorg.setup { + load = { + ["core.defaults"] = {}, -- Loads default behaviour + ["core.concealer"] = { + config = { + init_open_folds = "auto", + }, + }, -- Adds pretty icons to your documents + ["core.dirman"] = { -- Manages Neorg workspaces + config = { + workspaces = { + notes = workspace_root .. "/notes", + }, + default_workspace = "notes", + }, + }, + ["core.completion"] = { + config = { + engine = "nvim-cmp", + }, + }, + ["core.summary"] = {}, + ["core.manoeuvre"] = {}, + ["core.tangle"] = {}, + ["core.export"] = { + config = { + export_dir = "~/Sync/notes-export", + }, + }, + ["core.export.markdown"] = {}, + ["core.esupports.metagen"] = { + config = { + type = "auto", + }, + }, + --["core.ui.calendar"] = {}, -- Available with nvim 0.10+ + ["core.integrations.telescope"] = {}, + }, +} + +vim.keymap.set("n", "ni", function() + vim.cmd.Neorg("index") +end, { desc = "Toggle Notes" }) diff --git a/neovim-ide/plugin/noice.lua b/neovim-ide/plugin/noice.lua new file mode 100644 index 0000000..1436880 --- /dev/null +++ b/neovim-ide/plugin/noice.lua @@ -0,0 +1,23 @@ +local opts = { + cmdline = { + view = "cmdline", + }, + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +} +require("noice").setup(opts) + diff --git a/neovim-ide/plugin/telescope.lua b/neovim-ide/plugin/telescope.lua new file mode 100644 index 0000000..bad442d --- /dev/null +++ b/neovim-ide/plugin/telescope.lua @@ -0,0 +1,102 @@ +local telescope = require("telescope") +local actions = require("telescope.actions") +local builtin = require("telescope.builtin") +local telescope_config = require("telescope.config") + +-- Clone the default Telescope configuration +local vimgrep_arguments = { unpack(telescope_config.values.vimgrep_arguments) } + +-- I want to search in hidden/dot files. +table.insert(vimgrep_arguments, "--hidden") +-- I don't want to search in the `.git` directory. +table.insert(vimgrep_arguments, "--glob") +table.insert(vimgrep_arguments, "!**/.git/*") + + +local is_inside_work_tree = {} +local project_files = function() + local opts = {} -- define here if you want to define something + + local cwd = vim.fn.getcwd() + if is_inside_work_tree[cwd] == nil then + vim.fn.system("git rev-parse --is-inside-work-tree") + is_inside_work_tree[cwd] = vim.v.shell_error == 0 + end + + if is_inside_work_tree[cwd] then + builtin.git_files(opts) + else + builtin.find_files(opts) + end +end + +telescope.setup { + defaults = { + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + vimgrep_arguments = vimgrep_arguments, + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = true, + }, + width = 0.87, + height = 0.80, + preview_cutoff = 120, + }, + file_ignore_patterns = { "node_modules", "vendor" }, + path_display = { "truncate" }, + winblend = 3, + border = {}, + borderchars = { " ", " ", " ", " ", " ", " ", " ", " " }, + color_devicons = true, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + }, + ["ui-select"] = { + require("telescope.themes").get_dropdown({}) + } + }, + mappings = { + i = { + [""] = actions.close + }, + }, + pickers = { + find_files = { + -- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d. + find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" }, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +telescope.load_extension("fzf") +telescope.load_extension("noice") +telescope.load_extension("dap") +telescope.load_extension("ui-select") +-- +-- See `:help telescope.builtin` +vim.keymap.set("n", "fo", builtin.oldfiles, { desc = "Find recently opened files" }) +vim.keymap.set("n", "fb", builtin.buffers, { desc = "] Find existing buffers" }) +vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search Git Files" }) +vim.keymap.set("n", "ff", project_files, { desc = "Search Files" }) +vim.keymap.set("n", "sh", builtin.help_tags, { desc = "Search Help" }) +vim.keymap.set("n", "fG", builtin.grep_string, { desc = "Search current Word" }) +vim.keymap.set("n", "fg", builtin.live_grep, { desc = "Search by Grep" }) +vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "Search Diagnostics" }) +vim.keymap.set("n", "fr", builtin.resume, { desc = "Search Resume" }) diff --git a/neovim-ide/plugin/treesitter.lua b/neovim-ide/plugin/treesitter.lua new file mode 100644 index 0000000..e24abba --- /dev/null +++ b/neovim-ide/plugin/treesitter.lua @@ -0,0 +1,42 @@ +require("nvim-treesitter.configs").setup { + auto_install = false, + sync_install = false, + ignore_install = {}, + modules = {}, + ensure_installed = {}, + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + textobjects = { + select = { + enable = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = { + query = "@function.outer", + desc = "Select outer part of a function region", + }, + ["if"] = { + query = "@function.inner", + desc = "Select outer part of a function region", + }, + ["ac"] = { query = "@class.outer", "Select outer part of a class region" }, + ["ic"] = { + query = "@class.inner", + desc = "Select inner part of a class region", + }, + ["as"] = { + query = "@scope", + query_group = "locals", + desc = "Select language scope", + }, + }, + }, + }, + incremental_selection = { + enable = true, + }, +} diff --git a/neovim-ide/plugin/trouble.lua b/neovim-ide/plugin/trouble.lua new file mode 100644 index 0000000..d11619a --- /dev/null +++ b/neovim-ide/plugin/trouble.lua @@ -0,0 +1,18 @@ +require("trouble").setup() + +vim.keymap.set("n", "xx", vim.cmd.TroubleToggle, { desc = "Open Diagnostics" }) +vim.keymap.set("n", "xw", function() + vim.cmd.TroubleToggle("workspace_diagnostics") +end, { desc = "Open Workspace Trouble" }) +vim.keymap.set("n", "xd", function() + vim.cmd.TroubleToggle("document_diagnostics") +end, { desc = "Open Document Trouble" }) +vim.keymap.set("n", "xq", function() + vim.cmd.TroubleToggle("quickfix") +end, { desc = "Open Quickfix Trouble" }) +vim.keymap.set("n", "xl", function() + vim.cmd.TroubleToggle("loclist") +end, { desc = "Open Loclist Trouble" }) +vim.keymap.set("n", "gR", function() + vim.cmd.TroubleToggle("lsp_references") +end, { desc = "Open Loclist Trouble" }) diff --git a/neovim-ide/plugin/which-key.lua b/neovim-ide/plugin/which-key.lua new file mode 100644 index 0000000..ea448ea --- /dev/null +++ b/neovim-ide/plugin/which-key.lua @@ -0,0 +1,9 @@ +require("which-key").register { + ["c"] = { name = "Code", _ = "which_key_ignore" }, + ["d"] = { name = "Document", _ = "which_key_ignore" }, + ["g"] = { name = "Git", _ = "which_key_ignore" }, + ["h"] = { name = "More git", _ = "which_key_ignore" }, + ["r"] = { name = "Rename", _ = "which_key_ignore" }, + ["s"] = { name = "Search", _ = "which_key_ignore" }, + ["f"] = { name = "Find", _ = "which_key_ignore" }, +} diff --git a/neovim-ide/plugins.nix b/neovim-ide/plugins.nix new file mode 100644 index 0000000..1573746 --- /dev/null +++ b/neovim-ide/plugins.nix @@ -0,0 +1,97 @@ +{ pkgs, inputs, ... }: +let + nvimLib = pkgs.callPackage ../nix/lib { }; + inherit (nvimLib) mkNeovimPlugin; + vimPlugins = pkgs.vimPlugins; + + lsp = with vimPlugins; [ + nvim-lspconfig + lspkind-nvim + nvim-lightbulb + neodev-nvim + none-ls-nvim + ]; + + cmp = with vimPlugins; [ + cmp-buffer + cmp-cmdline + cmp-nvim-lsp + cmp-nvim-lsp-signature-help + cmp-path + cmp_luasnip + friendly-snippets + luasnip + nvim-cmp + ]; + + telescope = with vimPlugins; [ + telescope-dap-nvim + telescope-fzf-native-nvim + telescope-nvim + telescope-ui-select-nvim + ]; + + dap = with vimPlugins; [ + nvim-dap + nvim-dap-python + nvim-dap-ui + nvim-dap-virtual-text + ]; + + treesitter = with vimPlugins; [ + nvim-treesitter-textobjects + nvim-treesitter-textsubjects + nvim-treesitter.withAllGrammars + ]; + + neorg-nvim = with vimPlugins; [ + neorg + neorg-telescope + ]; + + rust = with vimPlugins; [ + rustaceanvim + crates-nvim + ]; + + go = with vimPlugins; [ + nvim-dap-go + (mkNeovimPlugin inputs.gopher-nvim "gopher.nvim") + ]; + + general = with vimPlugins; [ + catppuccin-nvim + gitsigns-nvim + indent-blankline-nvim + lazygit-nvim + lualine-lsp-progress + lualine-nvim + mini-nvim + neo-tree-nvim + noice-nvim + nvim-colorizer-lua + nvim-lastplace + nvim-web-devicons + rainbow-delimiters-nvim + tmux-nvim + todo-comments-nvim + trouble-nvim + undotree + vim-table-mode + which-key-nvim + ]; + + plugins = builtins.concatLists [ + general + lsp + telescope + dap + treesitter + cmp + neorg-nvim + rust + go + ]; +in +plugins + diff --git a/nix/lib/default.nix b/nix/lib/default.nix new file mode 100644 index 0000000..9c0408e --- /dev/null +++ b/nix/lib/default.nix @@ -0,0 +1,5 @@ +{ pkgs, lib, stdenv, ... }: { + mkNeovim = pkgs.callPackage ./mkNeovim.nix { }; + mkNeovimConfig = import ./mkNeovimConfig.nix { inherit pkgs lib stdenv; }; + mkNeovimPlugin = pkgs.callPackage ./mkNeovimPlugin.nix { }; +} diff --git a/nix/lib/mkNeovim.nix b/nix/lib/mkNeovim.nix new file mode 100644 index 0000000..781d9ab --- /dev/null +++ b/nix/lib/mkNeovim.nix @@ -0,0 +1,2 @@ +{ pkgs, ... }: +pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped diff --git a/nix/lib/mkNeovimConfig.nix b/nix/lib/mkNeovimConfig.nix new file mode 100644 index 0000000..b897ca8 --- /dev/null +++ b/nix/lib/mkNeovimConfig.nix @@ -0,0 +1,61 @@ +{ pkgs +, lib +, stdenv +, ... +}: +with lib; +{ runtimepath ? ../../nvim +, viAlias ? true +, vimAlias ? true +, withPython3 ? true +, extraPackages ? [ ] +, extraPython3Packages ? (_: [ ]) +, withNodeJs ? false +, withRuby ? true +, extraLuaPackages ? (_: [ ]) +, plugins ? [ ] +, customLuaRcContent ? "" +, ... +}: +let + rtp = stdenv.mkDerivation { + name = "neovim-runtimepath"; + src = runtimepath; + + buildPhase = '' + mkdir -p $out/nvim + ''; + + installPhase = '' + cp -r * $out/nvim + ''; + }; + + luaRcContent = + '' + vim.opt.runtimepath:prepend('${rtp}/nvim') + vim.opt.runtimepath:append('${rtp}/nvim/after') + ''; + + neovim = pkgs.neovimUtils.makeNeovimConfig { + inherit extraPython3Packages withPython3 withRuby withNodeJs viAlias vimAlias + plugins luaRcContent; + }; + + makeWrapperArgs = + let + binPath = lib.makeBinPath ( + lib.optionals + (extraPackages + != [ ]) + extraPackages); + in + [ ] ++ + lib.optionals (binPath != "") [ + "--suffix" + "PATH" + ":" + binPath + ]; +in +neovim // { wrapperArgs = makeWrapperArgs; } diff --git a/nix/lib/mkNeovimPlugin.nix b/nix/lib/mkNeovimPlugin.nix new file mode 100644 index 0000000..930d988 --- /dev/null +++ b/nix/lib/mkNeovimPlugin.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +src: pname: +pkgs.vimUtils.buildVimPlugin { + inherit pname src; + version = src.lastModifiedDate; +} diff --git a/nix/overlay.nix b/nix/overlay.nix new file mode 100644 index 0000000..7c34743 --- /dev/null +++ b/nix/overlay.nix @@ -0,0 +1,8 @@ +{ inputs, ... }: final: prev: +let + pkgs = final; +in +{ + neovim-ide = pkgs.callPackage ../neovim-ide { inherit inputs; }; + neovim-nightly = pkgs.callPackage ../neovim-nightly { inherit inputs; }; +}