Many things are working

This commit is contained in:
RingOfStorms (Joshua Bell) 2024-05-01 17:33:08 -05:00
parent c42f197307
commit 4582bd5469
20 changed files with 715 additions and 300 deletions

View file

@ -37,23 +37,24 @@ rm -rf ~/.local/state/nvim
## NOTES/TODOS
- Checkout cargo-bloat, cargo-cache, cargo-outdated - memcache sccache
- For scratches, just make an input box for custom extension rather than predefined list
- for find files, ignore git, capital F for find all
- better copilot alternatives? Local LLM usage only? etc?
- blacklist for undofile? .age files... etc
- generate command, like scratch open a popup of things that can be generated. UUID/other stuff?
- https://github.com/mawkler/nvim/blob/06cde9dbaedab2bb36c06025c07589c93d2c6d6b/lua/configs/luasnip.lua#L37-L50
- TODO learn more about augroup in autocommands.
- make my own session saving impl
- Only save visible buffers/tabs/splits
- per branch per directory
- something like https://github.com/gennaro-tedesco/nvim-possession/tree/main but fully managed
- plugins to install:
- rmagatti/auto-session - session management
- TODO look for alternatives? I am not a huge fan of this as it causes some issues on startup sometimes. I really only care about window placements and I want the rest to load naturally
- preservim/nerdcommenter - [un]comment support
- uga-rosa/ccc.nvim - color picker for hex codes etc
- zbirenbaum/copilot.lua
- Does github's work for me now? github/copilot.vim
- zbirenbaum/copilot-cmp
- chrisgrieser/nvim-early-retirement - auto close buffers
- voldikss/vim-floaterm
- GIT
- lewis6991/gitsigns.nvim
@ -65,8 +66,6 @@ rm -rf ~/.local/state/nvim
- RRethy/vim-illuminate - show token under cursor throughout file
- lukas-reineke/indent-blankline.nvim - indent lines
- TODO figure out tabs vs spaces thing with arrows vs bars.
- nvim-lualine/lualine.nvim
- TODO look at other buffer lines, is this still the best? What do others use?
- LSP stuff... figure out from scratch using kickstart/lazynvim as an example
- rust, ts, js, nix, lua,
- lvimuser/lsp-inlayhints.nvim L3MON4D3/LuaSnip hrsh7th/nvim-cmp williamboman/mason.nvim folke/neodev.nvim williamboman/mason-lspconfig.nvim neovim/nvim-lspconfig simrat39/rust-tools.nvim Saecki/crates.nvim
@ -79,14 +78,10 @@ rm -rf ~/.local/state/nvim
- Almo7aya/openingh.nvim
- tpope/vim-surround
- nvim-telescope/telescope-file-browser.nvim ?? do I want to keep this?
- nvim-telescope/telescope.nvim
- nvim-telescope/telescope-fzf-native.nvim
- nvim-telescope/telescope-ui-select.nvim (use this with scratch files?)
- johmsalas/text-case.nvim
- nvim-treesitter/nvim-treesitter
- mbbill/undotree
- nvim-lua/plenary.nvim
- rcarriga/nvim-notify ??? is this replaced by noice??
- folke/which-key.nvim
- check out

1
buffer_layout.json Normal file
View file

@ -0,0 +1 @@
[{"buf": 1, "col": 0, "row": 0, "bufname": "/home/josh/projects/nvim/README.md", "win": 1000, "width": 68, "height": 48}, {"buf": 10, "col": 69, "row": 0, "bufname": "/home/josh/projects/nvim/lua/util.lua", "win": 1001, "width": 68, "height": 12}, {"buf": 19, "col": 69, "row": 13, "bufname": "/home/josh/projects/nvim/init.lua", "win": 1002, "width": 68, "height": 35}]

155
flake.lock generated
View file

@ -33,6 +33,22 @@
"type": "indirect"
}
},
"nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": {
"flake": false,
"locked": {
"lastModified": 1713335068,
"narHash": "sha256-MnlhT17hR+tewbtLjaecxXxV1/ywzoqCL5MNtZsVYYk=",
"owner": "JoosepAlviste",
"repo": "nvim-ts-context-commentstring",
"rev": "a6382f744f584bbf71d0a563af789af7190aabda",
"type": "github"
},
"original": {
"owner": "JoosepAlviste",
"repo": "nvim-ts-context-commentstring",
"type": "github"
}
},
"nvim_plugin-MunifTanjim/nui.nvim": {
"flake": false,
"locked": {
@ -145,6 +161,118 @@
"type": "github"
}
},
"nvim_plugin-folke/which-key.nvim": {
"flake": false,
"locked": {
"lastModified": 1697801635,
"narHash": "sha256-uvghPj/teWrRMm09Gh8iQ/LV2nYJw0lmoiZK6L4+1cY=",
"owner": "folke",
"repo": "which-key.nvim",
"rev": "4433e5ec9a507e5097571ed55c02ea9658fb268a",
"type": "github"
},
"original": {
"owner": "folke",
"repo": "which-key.nvim",
"type": "github"
}
},
"nvim_plugin-nvim-lua/plenary.nvim": {
"flake": false,
"locked": {
"lastModified": 1714083960,
"narHash": "sha256-vy0MXEoSM4rvYpfwbc2PnilvMOA30Urv0FAxjXuvqQ8=",
"owner": "nvim-lua",
"repo": "plenary.nvim",
"rev": "08e301982b9a057110ede7a735dd1b5285eb341f",
"type": "github"
},
"original": {
"owner": "nvim-lua",
"repo": "plenary.nvim",
"type": "github"
}
},
"nvim_plugin-nvim-lualine/lualine.nvim": {
"flake": false,
"locked": {
"lastModified": 1712310396,
"narHash": "sha256-WcH2dWdRDgMkwBQhcgT+Z/ArMdm+VbRhmQftx4t2kNI=",
"owner": "nvim-lualine",
"repo": "lualine.nvim",
"rev": "0a5a66803c7407767b799067986b4dc3036e1983",
"type": "github"
},
"original": {
"owner": "nvim-lualine",
"repo": "lualine.nvim",
"type": "github"
}
},
"nvim_plugin-nvim-telescope/telescope-fzf-native.nvim": {
"flake": false,
"locked": {
"lastModified": 1709647247,
"narHash": "sha256-rycebls3g0JCHM2+aG7xlJnX7ZPowqviaLbQrFSdflM=",
"owner": "nvim-telescope",
"repo": "telescope-fzf-native.nvim",
"rev": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope-fzf-native.nvim",
"type": "github"
}
},
"nvim_plugin-nvim-telescope/telescope-ui-select.nvim": {
"flake": false,
"locked": {
"lastModified": 1701723223,
"narHash": "sha256-YRhNmmG4gx9Ht8JwjQfbTjJyTHEuZmtP6lqnhOsk8bE=",
"owner": "nvim-telescope",
"repo": "telescope-ui-select.nvim",
"rev": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope-ui-select.nvim",
"type": "github"
}
},
"nvim_plugin-nvim-telescope/telescope.nvim": {
"flake": false,
"locked": {
"lastModified": 1714530387,
"narHash": "sha256-lQl0UwUfHhPjJHWbNTR10NB+GATJUiD3lRESEdduX7w=",
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "2d0d057791854decb2c9b6a0b52d43f3900dff40",
"type": "github"
},
"original": {
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"type": "github"
}
},
"nvim_plugin-preservim/nerdcommenter": {
"flake": false,
"locked": {
"lastModified": 1702928950,
"narHash": "sha256-zQy5VN2w9Hqo0Is7Yp2fm1WvBV6QNJwhHm0eozh69TI=",
"owner": "preservim",
"repo": "nerdcommenter",
"rev": "e361a44230860d616f799a337bc58f5218ab6e9c",
"type": "github"
},
"original": {
"owner": "preservim",
"repo": "nerdcommenter",
"type": "github"
}
},
"nvim_plugin-rcarriga/nvim-notify": {
"flake": false,
"locked": {
@ -161,10 +289,27 @@
"type": "github"
}
},
"nvim_plugin-windwp/nvim-ts-autotag": {
"flake": false,
"locked": {
"lastModified": 1707265789,
"narHash": "sha256-cPIEIjcYxX3ZkOyou2mYlHMdhBxCoVTpJVXZtiWe9Ks=",
"owner": "windwp",
"repo": "nvim-ts-autotag",
"rev": "531f48334c422222aebc888fd36e7d109cb354cd",
"type": "github"
},
"original": {
"owner": "windwp",
"repo": "nvim-ts-autotag",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring",
"nvim_plugin-MunifTanjim/nui.nvim": "nvim_plugin-MunifTanjim/nui.nvim",
"nvim_plugin-Pocco81/auto-save.nvim": "nvim_plugin-Pocco81/auto-save.nvim",
"nvim_plugin-catppuccin/nvim": "nvim_plugin-catppuccin/nvim",
@ -172,7 +317,15 @@
"nvim_plugin-declancm/cinnamon.nvim": "nvim_plugin-declancm/cinnamon.nvim",
"nvim_plugin-folke/lazy.nvim": "nvim_plugin-folke/lazy.nvim",
"nvim_plugin-folke/noice.nvim": "nvim_plugin-folke/noice.nvim",
"nvim_plugin-rcarriga/nvim-notify": "nvim_plugin-rcarriga/nvim-notify"
"nvim_plugin-folke/which-key.nvim": "nvim_plugin-folke/which-key.nvim",
"nvim_plugin-nvim-lua/plenary.nvim": "nvim_plugin-nvim-lua/plenary.nvim",
"nvim_plugin-nvim-lualine/lualine.nvim": "nvim_plugin-nvim-lualine/lualine.nvim",
"nvim_plugin-nvim-telescope/telescope-fzf-native.nvim": "nvim_plugin-nvim-telescope/telescope-fzf-native.nvim",
"nvim_plugin-nvim-telescope/telescope-ui-select.nvim": "nvim_plugin-nvim-telescope/telescope-ui-select.nvim",
"nvim_plugin-nvim-telescope/telescope.nvim": "nvim_plugin-nvim-telescope/telescope.nvim",
"nvim_plugin-preservim/nerdcommenter": "nvim_plugin-preservim/nerdcommenter",
"nvim_plugin-rcarriga/nvim-notify": "nvim_plugin-rcarriga/nvim-notify",
"nvim_plugin-windwp/nvim-ts-autotag": "nvim_plugin-windwp/nvim-ts-autotag"
}
},
"systems": {

View file

@ -11,6 +11,10 @@
url = "github:folke/lazy.nvim";
flake = false;
};
"nvim_plugin-nvim-lua/plenary.nvim" = {
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
"nvim_plugin-catppuccin/nvim" = {
url = "github:catppuccin/nvim";
flake = false;
@ -35,11 +39,46 @@
url = "github:folke/noice.nvim";
flake = false;
};
# TODO TELESCOPE
"nvim_plugin-declancm/cinnamon.nvim" = {
url = "github:declancm/cinnamon.nvim";
flake = false;
};
"nvim_plugin-nvim-lualine/lualine.nvim" = {
url = "github:nvim-lualine/lualine.nvim";
flake = false;
};
"nvim_plugin-folke/which-key.nvim" = {
url = "github:folke/which-key.nvim";
flake = false;
};
"nvim_plugin-nvim-telescope/telescope.nvim" = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
"nvim_plugin-nvim-telescope/telescope-fzf-native.nvim" = {
url = "github:nvim-telescope/telescope-fzf-native.nvim";
flake = false;
};
"nvim_plugin-nvim-telescope/telescope-ui-select.nvim" = {
url = "github:nvim-telescope/telescope-ui-select.nvim";
flake = false;
};
"nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring" = {
url = "github:JoosepAlviste/nvim-ts-context-commentstring";
flake = false;
};
"nvim_plugin-preservim/nerdcommenter" = {
url = "github:preservim/nerdcommenter";
flake = false;
};
"nvim_plugin-windwp/nvim-ts-autotag" = {
url = "github:windwp/nvim-ts-autotag";
flake = false;
};
# "nvim_plugin-nvim-treesitter/nvim-treesitter" = {
# url = "github:nvim-treesitter/nvim-treesitter";
# flake = false;
# };
};
outputs = { self, nixpkgs, flake-utils, ... } @ inputs:
@ -49,6 +88,9 @@
pkgs = nixpkgs.legacyPackages.${system};
lib = nixpkgs.lib;
nonFlakePluginPaths = {
"nvim_plugin-nvim-treesitter/nvim-treesitter" = pkgs.vimPlugins.nvim-treesitter.withAllGrammars;
};
# This will be how we put any nix related stuff into our lua config
luaNixGlobal = "NIX=" + lib.generators.toLua { multiline = false; indent = false; } ({
storePath = "${./.}";
@ -58,7 +100,7 @@
{
"${name}" = inputs.${name}.outPath;
} // dirs)
{ }
nonFlakePluginPaths
(builtins.filter
(n: builtins.substring 0 12 n == "nvim_plugin-")
(builtins.attrNames inputs));
@ -69,11 +111,10 @@
fd # search
fzf # search fuzzy
curl # http requests
tree-sitter
glow # markdown renderer
nodePackages.cspell
] ++ builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins;
# treesitterParsers = builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins;
];
in
{
packages = {
@ -86,8 +127,8 @@
customRC = ''
lua ${luaNixGlobal}
luafile ${./.}/init.lua
set runtimepath^=${builtins.concatStringsSep "," (builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins)}
'';
# set runtimepath^=${builtins.concatStringsSep "," treesitterParsers}
})
).overrideAttrs
(old: {
@ -116,27 +157,7 @@
"XDG_STATE_HOME"
"/tmp/nvim_flaked/state"
];
})
;
# neovim = pkgs.stdenv.mkDerivation {
# name = "nvim";
# nativeBuildInputs = with pkgs; [ makeWrapper rsync ];
# buildInputs = with pkgs; [ neovim cowsay ];
# unpackPhase = ":";
# installPhase = ''
# mkdir -p $out/bin
# cp ${pkgs.neovim}/bin/nvim $out/bin/nvim
# wrapProgram $out/bin/nvim --run "
# export XDG_CONFIG_HOME=$out/config
# "
# mkdir -p $out/share/nvim
# rsync -a ${source}/ $out/share/nvim
# ln -s ${pkgs.cowsay}/bin/cowsay $out/bin/cowsay
# '';
# # ln -s ${cpsell}/bin/cpsell $out/bin/cpsell
# };
});
};
});

View file

@ -4,8 +4,10 @@ if NIX then
-- However this pollutes the path, it could be limited to just init files but this approach here one level deep is adequate for my own needs
package.path = package.path .. ";" .. NIX.storePath .. "/lua/?.lua"
package.path = package.path .. ";" .. NIX.storePath .. "/lua/?/init.lua"
print(vim.inspect(NIX))
end
U = require("util") -- NOTE global U[til]
require("options")
require("keymaps")
@ -35,7 +37,7 @@ vim.opt.rtp:prepend(lazypath)
local function ensure_table(object)
return type(object) == "table" and object or { object }
end
function getSpec()
local function getSpec()
if NIX then
-- Convert plugins to use nix store, this auto sets the `dir` property for us on all plugins.
function convertPluginToNixStore(plugin)
@ -85,8 +87,3 @@ require("lazy").setup({
vim.cmd("colorscheme catppuccin")
require("tools")
require("autocommands")
-- - **LazyDone**when lazy has finished starting up and loaded your config
-- - **VeryLazy**triggered after `LazyDone` and processing `VimEnter` auto commands
-- - **LazyVimStarted**triggered after `UIEnter` when `require("lazy").stats().startuptime` has been calculated.
-- Useful to update the startuptime on your dashboard.

View file

@ -1,4 +1,3 @@
local util = require("util")
-- Remap space as leader key
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
vim.g.mapleader = " "
@ -14,10 +13,8 @@ vim.g.maplocalleader = " "
local nvx = { "n", "v", "x" }
util.keymaps({
-- ===========
-- Basic
-- ===========
U.keymaps({
-- Basic
{ "<left>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx },
{ "<right>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx },
{ "<up>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx },
@ -26,19 +23,33 @@ util.keymaps({
{ "<leader>Q", "<nop>", mode = nvx }, -- don't do normal Q quit
{ "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx },
{ "Q", "<cmd>qa<CR>", desc = "Quit all", mode = nvx },
{
"<leader>QQ",
-- TODO REVISIT is this session stuff still relevant?
"<cmd>NvimTreeClose<cr><cmd>SessionDelete<cr><cmd>qa<CR>",
desc = "Quit all, no session saved",
mode = nvx,
},
-- {
-- "<leader>QQ",
-- -- TODO REVISIT is this session stuff still relevant?
-- "<cmd>NvimTreeClose<cr><cmd>SessionDelete<cr><cmd>qa<CR>",
-- desc = "Quit all, no session saved",
-- mode = nvx,
-- },
{ "<leader>y", '"+y', desc = "Copy to system clipboard", mode = nvx },
{ "<leader>p", '"+p', desc = "Paste from system clipboard", mode = nvx },
{ "<esc>", "<cmd>nohlsearch<CR><esc>", desc = "Clear search on escape" },
{ "<return>", "<cmd>nohlsearch<CR><return>", desc = "Clear search on return" },
{ "|", "<cmd>vsplit<cr>", desc = "Vertical Split" },
{ "\\", "<cmd>split<cr>", desc = "Horizontal Split" },
{ "<S-Tab>", "<C-o>", desc = "Go back <C-o>" },
{
"J",
":m '>+1<CR>gv=gv",
desc = "Visually move block down",
mode = "v",
},
{
"K",
":m '<-2<CR>gv=gv",
desc = "Visually move block up",
mode = "v",
},
{ "<Esc>", "<C-\\><C-n>", desc = "Escape the terminal", mode = "t" },
-- Buffers
{ "<leader>b", "<cmd>b#<cr>", desc = "Switch to last buffer", mode = nvx },
@ -51,7 +62,7 @@ util.keymaps({
-- * if empty buffer, then we will quit this buffer
local close_always = { "quickfix", "help", "nofile" }
if
util.table_contains(close_always, vim.bo.buftype)
U.table_contains(close_always, vim.bo.buftype)
or (vim.api.nvim_buf_line_count(0) == 1 and vim.api.nvim_buf_get_lines(0, 0, 1, -1)[1] == "")
then
vim.cmd("silent confirm q")
@ -73,6 +84,30 @@ util.keymaps({
{ "<C-k>", "<C-W>k", desc = "Move window above current", mode = nvx },
{ "<C-l>", "<C-W>l", desc = "Move window right current", mode = nvx },
-- Editor
{ "J", "mzJ`z", desc = "Move line below onto this line" },
{ -- TODO stay here, are these already mapped?
"]d",
vim.diagnostic.goto_next,
desc = "Go to next diagnostic message",
},
{
"[d",
vim.diagnostic.goto_prev,
desc = "Go to previous diagnostic message",
},
{ ">", "> gv", desc = "Indent selection", mode = "v" },
{ "<", "< gv", desc = "Outdent selection", mode = "v" },
{ "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" },
-- TODO take <leader>r from http requests?
{ "<C-r>", '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection", mode = "v" },
{ "<C-k>", "<Up>", desc = "Up", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-j>", "<Down>", desc = "Down", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-h>", "<Left>", desc = "Left", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-l>", "<Right>", desc = "Right", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-4>", "<End>", desc = "End", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-6>", "<Home>", desc = "Home", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
-- Tabs
-- TODO revisit, do I even need these tab things?
{ "<leader>tn", "<cmd>tabnew<cr>", desc = "Create new tab", mode = nvx },
@ -80,7 +115,7 @@ util.keymaps({
{ "H", "<cmd>tabprevious<cr>", desc = "Move to previous tab" },
{ "L", "<cmd>tabnext<cr>", desc = "Move to next tab" },
-- LSP/IDE/etc
-- LSP/IDE/etc TODO move to lsp config file
{
"<leader>l<leader>",
vim.lsp.buf.format,
@ -99,76 +134,4 @@ util.keymaps({
desc = "Show diagnostics in quickfix list",
mode = nvx,
},
-- =============
-- =============
-- =============
-- =============
-- =============
-- =============
-- =============
-- normal mode
-- =============
-- { "", "", desc = "" },
-- { "n", "nzzzv", desc = "Next search result centered" },
-- { "N", "Nzzzv", desc = "Previous search result centered" },
-- { "<C-d>", "<C-d>zz", desc = "Vertical half page down and center cursor" },
-- { "<C-u>", "<C-u>zz", desc = "Vertical half page up and center cursor" },
{ "J", "mzJ`z", desc = "Move line below onto this line" },
{ "<S-Tab>", "<C-o>", desc = "Go back <C-o>" },
{
"]d",
vim.diagnostic.goto_next,
desc = "Go to next diagnostic message",
},
{
"[d",
vim.diagnostic.goto_prev,
desc = "Go to previous diagnostic message",
},
-- =============
-- VISUAL
-- =============
{
"J",
":m '>+1<CR>gv=gv",
desc = "Visually move block down",
mode = "v",
},
{
"K",
":m '<-2<CR>gv=gv",
desc = "Visually move block up",
mode = "v",
},
{
"<leader>,uu",
'd:let @u = trim(tolower(system("uuidgen")))<cr>i<C-r>u',
desc = "Generate and replace UUID",
mode = "v",
},
{ "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" },
{ "<C-r>", '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection", mode = "v" },
{ ">", "> gv", desc = "Indent selection", mode = "v" },
{ "<", "< gv", desc = "Outdent selection", mode = "v" },
-- =============
-- insert / command
-- =============
{ "<C-k>", "<Up>", desc = "Up", mode = { "i", "c" } },
{ "<C-j>", "<Down>", desc = "Down", mode = { "i", "c" } },
{ "<C-h>", "<Left>", desc = "Left", mode = { "i", "c" } },
{ "<C-l>", "<Right>", desc = "Right", mode = { "i", "c" } },
{ "<C-4>", "<End>", desc = "End", mode = { "i", "c" } },
{ "<C-6>", "<Home>", desc = "Home", mode = { "i", "c" } },
-- =============
-- command
-- =============
-- { mode = "c" }
-- =============
-- terminal
-- =============
{ "<Esc>", "<C-\\><C-n>", desc = "Escape the terminal", mode = "t" },
})

View file

@ -42,7 +42,7 @@ vim.opt.expandtab = true
-- Dont use swap files, use undotree
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = vim.fn.stdpath("state") .. "/undodir"
vim.opt.undodir = vim.fn.stdpath("data") .. "/undodir"
vim.opt.undofile = true
-- Sets how neovim will display certain whitespace characters in the editor.

View file

@ -2,6 +2,11 @@ return {
"Pocco81/auto-save.nvim",
event = "BufEnter",
opts = {
execution_message = {
message = function()
return ""
end,
},
trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" },
condition = function(buf)
local disallowed_filetypes = { "TelescopePrompt", "quickfix", "terminal" }

View file

@ -0,0 +1,26 @@
return {
"preservim/nerdcommenter",
dependencies = {
{
-- This will auto change the commentstring option in files that could have varying
-- comment modes like in jsx/markdown/files with embedded languages
"JoosepAlviste/nvim-ts-context-commentstring",
init = function()
-- skip backwards compatibility routines and speed up loading
vim.g.skip_ts_context_commentstring_module = true
end,
config = function()
require("ts_context_commentstring").setup({})
end,
},
},
config = function()
vim.g.NERDCreateDefaultMappings = 0
vim.g.NERDDefaultAlign = "both"
vim.g.NERDSpaceDelims = 1
vim.cmd("filetype plugin on")
end,
keys = {
{ "<leader>/", "<Plug>NERDCommenterToggle<cr>k", mode = { "n", "x" } },
},
}

View file

@ -4,7 +4,5 @@ return {
event = "VeryLazy",
opts = {
retirementAgeMins = 1,
notificationOnAutoClose = true,
-- deleteBufferWhenFileDeleted = true,
},
}

View file

@ -0,0 +1,127 @@
-- TODO checkout https://github.com/nvim-lua/lsp-status.nvim
local function lsp_clients()
local clients = {}
for _, client in pairs(vim.lsp.buf_get_clients(0)) do
local name = client.name
-- TODO revisit this doesn't work
if not client.initialized then
name = name .. " (loading)"
end
clients[#clients + 1] = name
end
table.sort(clients)
return table.concat(clients, ""), ""
end
local function langs()
local l = {}
for _, client in pairs(vim.lsp.buf_get_clients(0)) do
local out = nil
if client.name == "pyright" then
out = vim.fn.system({ "python", "-V" })
elseif client.name == "tsserver" then
out = "node " .. vim.fn.system({ "node", "--version" })
end
if out ~= nil and out ~= "" then
l[#l + 1] = vim.trim(out)
end
end
table.sort(l)
return table.concat(l, ""), ""
end
local function latest_message()
return U.safeRequire("noice", function(n)
return n.api.status.message.get_hl
end, U.fnEmptyStr)
end
local function latest_message_cond()
return U.safeRequire("noice", function(n)
return n.api.status.message.has
end, U.fnFalse)
end
return {
"nvim-lualine/lualine.nvim",
dependencies = { { "folke/noice.nvim", optional = true } },
lazy = false,
opts = function()
return {
options = {
theme = "codedark",
section_separators = { left = "", right = "" },
component_separators = "|",
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = {
{ "filename", separator = { right = "" } },
{ "reg_recording", icon = { "󰻃" }, color = { fg = "#D37676" } },
{ latest_message, cond = latest_message_cond },
},
lualine_x = {
lsp_clients,
langs,
"encoding",
"filetype",
"filesize",
},
lualine_y = { "searchcount", "selectioncount" },
lualine_z = { "location" },
},
winbar = {
lualine_a = {
{
"filename",
symbols = {
modified = "", -- Text to show when the file is modified.
readonly = "[-]", -- Text to show when the file is non-modifiable or readonly.
unnamed = "[No Name]", -- Text to show for unnamed buffers.
newfile = "[New]", -- Text to show for newly created file before first write
},
},
},
lualine_b = {
"mode",
},
},
inactive_winbar = {
lualine_a = {
{
"filename",
symbols = {
modified = "", -- Text to show when the file is modified.
readonly = "[-]", -- Text to show when the file is non-modifiable or readonly.
unnamed = "[No Name]", -- Text to show for unnamed buffers.
newfile = "[New]", -- Text to show for newly created file before first write
},
},
},
},
}
end,
config = function(_, opts)
require("lualine").setup(opts)
local ref = function()
require("lualine").refresh({
place = { "statusline" },
})
end
vim.api.nvim_create_autocmd("RecordingEnter", {
callback = ref,
})
vim.api.nvim_create_autocmd("RecordingLeave", {
callback = function()
local timer = vim.loop.new_timer()
timer:start(50, 0, vim.schedule_wrap(ref))
end,
})
end,
}

View file

@ -2,12 +2,12 @@ return {
"folke/noice.nvim",
event = "VeryLazy",
opts = {
cmdline = {
format = {
conceal = {
pattern = "^noh"
},
},
messages = {
view = "mini", -- default view for messages
view_error = "notify", -- view for errors
view_warn = "mini", -- view for warnings
view_history = "messages", -- view for :messages
view_search = false, -- view for search count messages. Set to `false` to disable
},
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**

View file

@ -1,27 +1,12 @@
return {
"rcarriga/nvim-notify",
-- dependencies = { "nvim-telescope/telescope.nvim", optional = true },
lazy = false,
priority = 999,
priority = 150,
opts = {
top_down = false,
timeout = 3000,
timeout = 5000,
},
config = function(_, opts)
require("notify").setup(opts)
vim.notify = require("notify")
-- TODO move to telescope instead...
-- if package.loaded["telescope"] then
-- require("telescope").load_extension("notify")
-- require("util").keymaps({
-- {
-- "<leader>fn",
-- "<cmd>Telescope notify<cr>",
-- desc = "Telescope search notifications",
-- mode = { "n", "v", "x" },
-- },
-- })
-- end
end,
}

View file

@ -0,0 +1,32 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 250
end,
opts = {
window = {
border = "single",
winblend = 10,
},
},
config = function(_, opts)
local wk = require("which-key")
wk.setup(opts)
wk.register({
["<leader>b"] = { name = "Buffers" },
["<leader>t"] = { name = "Tabs" },
-- ["<leader>,"] = { name = "Miscellaneous Tools" },
-- ["<leader>c"] = { name = "Copilot" },
["<leader>f"] = { name = "Find [Telescope]" },
-- ["<leader>fs"] = { name = "Find in Scratches [Telescope]" },
-- ["<leader>g"] = { name = "Git" },
["<leader>l"] = { name = "LSP" },
["<leader>lf"] = { name = "LSP Find" },
-- ["<leader>Q"] = { name = "+Q Quit and remove session" },
-- ["<leader>s"] = { name = "Scratch Files" },
-- ["<leader>x"] = { name = "Generative AI, Ollama" },
})
end,
}

154
lua/plugins/telescope.lua Normal file
View file

@ -0,0 +1,154 @@
return {
"nvim-telescope/telescope.nvim",
dependencies = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-telescope/telescope-fzf-native.nvim" },
{ "nvim-telescope/telescope-ui-select.nvim" },
},
init = function()
U.cmd_executable("rg", {
[false] = function()
vim.notify("rg not installed, live grep will not function.", 2)
end,
})
end,
cmd = "Telescope",
opts = function()
return {
pickers = {
buffers = {
sort_lastused = true,
},
find_files = {
hidden = true,
sort_lastused = true,
},
live_grep = {
hidden = true,
},
},
defaults = {
file_ignore_patterns = { "node_modules", "package-lock.json", "target", ".git" },
mappings = {
i = {
["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous",
},
},
vimgrep_arguments = {
"rg",
"--hidden",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_cursor(),
},
["notify"] = {},
},
}
end,
config = function(_, opts)
local ts = require("telescope")
ts.setup(opts)
ts.load_extension("ui-select")
if package.loaded["notify"] then
ts.load_extension("notify")
U.keymaps({
{
"<leader>fn",
"<cmd>Telescope notify<cr>",
desc = "Telescope search notifications",
mode = { "n", "v", "x" },
},
})
end
end,
-- https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#pickers
keys = {
{
"<leader>fr",
function()
require("telescope.builtin").resume()
end,
desc = "Resume last telescope",
},
{
"<leader>fj",
function()
require("telescope.builtin").current_buffer_fuzzy_find()
end,
desc = "Fuzzy find/search in current buffer fuzzy.",
},
{
"<leader>ff",
function()
require("telescope.builtin").find_files({
hidden = true,
})
end,
desc = "Find Files",
},
{
"<leader>fg",
function()
require("telescope.builtin").git_files({
hidden = true,
})
end,
desc = "Find Git only Files",
},
{
"<leader>fw",
function()
U.cmd_executable("rg", {
function()
require("telescope.builtin").live_grep({
hidden = true,
})
end,
function()
vim.notify("rg not installed, find words will not function.", 3)
end,
})
end,
desc = "Find Words",
},
{
"<leader>fc",
function()
require("telescope.builtin").commands()
end,
desc = "Find Commands",
},
{
"<leader>fk",
function()
require("telescope.builtin").keymaps()
end,
desc = "Find Commands",
},
{
"<leader>fb",
function()
require("telescope.builtin").buffers()
end,
desc = "Find Commands",
},
{
"<leader>lfr",
function()
require("telescope.builtin").lsp_references()
end,
desc = "Find References",
mode = { "n", "v", "x" },
},
},
}

View file

@ -0,0 +1,56 @@
return {
"nvim-treesitter/nvim-treesitter",
dependencies = { "windwp/nvim-ts-autotag", "JoosepAlviste/nvim-ts-context-commentstring" },
init = function()
U.cmd_executable("tree-sitter", {
[false] = function()
vim.notify("tree-sitter not installed, code syntax will be broken.", 2)
end,
})
end,
event = "BufRead",
cmd = {
"TSBufDisable",
"TSBufEnable",
"TSBufToggle",
"TSDisable",
"TSEnable",
"TSToggle",
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSModuleInfo",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
},
opts = function()
local nonNixOpts = {}
if not NIX then
nonNixOpts = {
ensure_installed = "all",
}
end
return U.assign({
highlight = {
enable = true,
use_languagetree = true,
disable = function(_, bufnr)
return vim.api.nvim_buf_line_count(bufnr) > 10000
end,
-- additional_vim_regex_highlighting = false,
},
incremental_selection = { enable = true },
ident = { enable = true },
autotag = { enable = true },
rainbow = {
enable = true,
extended_mode = true,
max_file_lines = nil,
},
}, nonNixOpts)
end,
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
}

View file

@ -1,5 +1,5 @@
-- Require all files in this tools dir, minus this init.lua file
function script_path()
local function script_path()
return debug.getinfo(2, "S").source:sub(2):match("(.*/)")
end
-- Extract the directory name from the script path

View file

@ -1,11 +1,12 @@
-- Function to remove item from quickfix list
function RemoveQFItem()
local curqfidx = vim.fn.line(".") - 1
local qfall = vim.fn.getqflist()
table.remove(qfall, curqfidx + 1) -- Lua is 1-indexed
vim.fn.setqflist(qfall, "r")
vim.cmd(curqfidx .. "cfirst")
vim.cmd("copen")
local function RemoveQFItem()
local currentIndex = vim.fn.line(".") - 1
local quickfixList = vim.fn.getqflist()
-- Remove current item and replace the quickfix list
table.remove(quickfixList, currentIndex + 1) -- Lua is 1-indexed
vim.fn.setqflist(quickfixList, "r")
-- Keep cursor on the line it was +1 (so it goes to next item rather than back up)
vim.cmd("cwindow | :" .. (currentIndex + 1))
end
-- Command to call the function

View file

@ -63,6 +63,7 @@ function M.keymap(keymap)
end
end
-- spread({})({})
function M.spread(template)
local result = {}
for key, value in pairs(template) do
@ -77,6 +78,14 @@ function M.spread(template)
end
end
-- assign({}, {})
function M.assign(obj, assign)
for key, value in pairs(assign) do
obj[key] = value
end
return obj
end
function M.table_contains(table, element)
for _, value in pairs(table) do
if value == element then
@ -109,4 +118,30 @@ function M.highlight(group, options)
)
end
function M.safeRequire(module, func, errorFunc)
local ok, result = pcall(require, module)
if ok then
return func(result)
elseif errorFunc then
return errorFunc(result)
end
return nil
end
function M.fnFalse()
return false
end
function M.fnNil()
return nil
end
function M.fnEmptyStr()
return ""
end
function M.fnZero()
return 0
end
return M

134
test.nix
View file

@ -1,134 +0,0 @@
{
outputs =
{ self
, nixpkgs
, neovim-src
, ...
}:
let
inherit (nixpkgs) lib;
#
# Funni helper function
#
withSystem =
f:
lib.fold lib.recursiveUpdate { } (
map f [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
]
);
in
withSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
#
# Linter and formatter, run with "nix fmt"
# You can use alejandra or nixpkgs-fmt instead of nixfmt if you wish
#
formatter.${system} = pkgs.writeShellApplication {
name = "lint";
runtimeInputs = [
pkgs.nixfmt-rfc-style
pkgs.deadnix
pkgs.statix
pkgs.fd
pkgs.stylua
];
text = ''
fd '.*\.nix' . -x statix fix -- {} \;
fd '.*\.nix' . -X deadnix -e -- {} \; -X nixfmt {} \;
fd '.*\.lua' . -X stylua --indent-type Spaces --indent-width 2 {} \;
'';
};
packages.${system} = {
default = self.packages.${system}.neovim;
neovim =
(pkgs.wrapNeovimUnstable
(pkgs.neovim-unwrapped.overrideAttrs {
#
# Use neovim nightly
#
src = neovim-src;
version = neovim-src.shortRev or "dirty";
patches = [ ];
preConfigure = ''
sed -i cmake.config/versiondef.h.in -e "s/@NVIM_VERSION_PRERELEASE@/-dev-$version/"
'';
})
(
pkgs.neovimUtils.makeNeovimConfig {
plugins =
[
#
# Add plugins from nixpkgs here
#
pkgs.vimPlugins.nvim-treesitter.withAllGrammars
]
++ lib.mapAttrsToList
(
#
# This generates plugins from npins sources
#
name: src: (pkgs.vimUtils.buildVimPlugin { inherit name src; })
)
(import ./npins/sources.nix pkgs);
#
# Use the string generated in ./lua/default.nix for init.vim
#
customRC = import ./lua { inherit lib self; };
}
)
).overrideAttrs
(old: {
generatedWrapperArgs = old.generatedWrapperArgs or [ ] ++ [
"--prefix"
"PATH"
":"
(lib.makeBinPath [
#
# Runtime dependencies
#
pkgs.deadnix
pkgs.statix
pkgs.nil
pkgs.ripgrep
pkgs.fd
pkgs.lua-language-server
pkgs.stylua
])
];
});
};
}
);
inputs = {
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
neovim-src = {
type = "github";
owner = "neovim";
repo = "neovim";
ref = "f694d020c576fb037eb92bae3bbf03a69d8686b6";
flake = false;
};
flake-compat = {
type = "github";
owner = "edolstra";
repo = "flake-compat";
flake = false;
};
};
}