WIP on new config

This commit is contained in:
RingOfStorms (Joshua Bell) 2024-05-01 01:14:46 -05:00
parent c86f67f0f7
commit c42f197307
13 changed files with 354 additions and 85 deletions

View file

@ -2,6 +2,7 @@
Goals:
- Works with or without nix
- LSP integration with the current project's settings if available
## Running
@ -41,10 +42,10 @@ rm -rf ~/.local/state/nvim
- 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
- TODO learn more about augroup in autocommands.
- plugins to install:
- pocco81/auto-save.nvim
- folke/noice.nvim - messages/cmdline/popupmenu updates
- 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
@ -74,6 +75,7 @@ rm -rf ~/.local/state/nvim
- lnc3l0t/glow.nvim - markdown preview
- null_ls replacement?? need a formater replacement, diff between lsp reformat?
- cspell? vs built in spell check?
- Lets use https://github.com/mfussenegger/nvim-lint
- Almo7aya/openingh.nvim
- tpope/vim-surround
- nvim-telescope/telescope-file-browser.nvim ?? do I want to keep this?
@ -88,10 +90,7 @@ rm -rf ~/.local/state/nvim
- folke/which-key.nvim
- check out
- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-bufremove.md
- OR https://github.com/famiu/bufdelete.nvim
- https://github.com/onsails/lspkind.nvim
- declancm/cinnamon.nvim - smooth scroll effect
- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-align.md
- plugins I decided to remove from my old config

104
flake.lock generated
View file

@ -33,6 +33,38 @@
"type": "indirect"
}
},
"nvim_plugin-MunifTanjim/nui.nvim": {
"flake": false,
"locked": {
"lastModified": 1710740032,
"narHash": "sha256-Zr5CNx6BIM6naCXW8YBc/Oj1qOtWV/3tuMoaaZjoSZA=",
"owner": "MunifTanjim",
"repo": "nui.nvim",
"rev": "cbd2668414331c10039278f558630ed19b93e69b",
"type": "github"
},
"original": {
"owner": "MunifTanjim",
"repo": "nui.nvim",
"type": "github"
}
},
"nvim_plugin-Pocco81/auto-save.nvim": {
"flake": false,
"locked": {
"lastModified": 1667329943,
"narHash": "sha256-bWGil73YiCKZEaY7IuUOIU4Q7k7qCMjSeQ4I+cAVe44=",
"owner": "Pocco81",
"repo": "auto-save.nvim",
"rev": "979b6c82f60cfa80f4cf437d77446d0ded0addf0",
"type": "github"
},
"original": {
"owner": "Pocco81",
"repo": "auto-save.nvim",
"type": "github"
}
},
"nvim_plugin-catppuccin/nvim": {
"flake": false,
"locked": {
@ -49,6 +81,38 @@
"type": "github"
}
},
"nvim_plugin-chrisgrieser/nvim-early-retirement": {
"flake": false,
"locked": {
"lastModified": 1706108060,
"narHash": "sha256-5lpGqHg0jrLawr2A8mNwADHG62A92By6ZpZeqzd2uUs=",
"owner": "chrisgrieser",
"repo": "nvim-early-retirement",
"rev": "8d83da8a5e5dd29e35a291fcb1c47290df9b7699",
"type": "github"
},
"original": {
"owner": "chrisgrieser",
"repo": "nvim-early-retirement",
"type": "github"
}
},
"nvim_plugin-declancm/cinnamon.nvim": {
"flake": false,
"locked": {
"lastModified": 1714107684,
"narHash": "sha256-cMP9WRZzevxaWgpILyDh1JwNukm3Jl3JKJYPT2HnFns=",
"owner": "declancm",
"repo": "cinnamon.nvim",
"rev": "a011e84b624cd7b609ea928237505d31b987748a",
"type": "github"
},
"original": {
"owner": "declancm",
"repo": "cinnamon.nvim",
"type": "github"
}
},
"nvim_plugin-folke/lazy.nvim": {
"flake": false,
"locked": {
@ -65,12 +129,50 @@
"type": "github"
}
},
"nvim_plugin-folke/noice.nvim": {
"flake": false,
"locked": {
"lastModified": 1711471279,
"narHash": "sha256-y6gHNkWVsIuwBf7MblCTKTZSqjGDxqeFeQZWexzwk94=",
"owner": "folke",
"repo": "noice.nvim",
"rev": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12",
"type": "github"
},
"original": {
"owner": "folke",
"repo": "noice.nvim",
"type": "github"
}
},
"nvim_plugin-rcarriga/nvim-notify": {
"flake": false,
"locked": {
"lastModified": 1708161547,
"narHash": "sha256-xJYPOX4YLcWojMCdP1RO22/7FMrbcBQxqxrcVCE2TrU=",
"owner": "rcarriga",
"repo": "nvim-notify",
"rev": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15",
"type": "github"
},
"original": {
"owner": "rcarriga",
"repo": "nvim-notify",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"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",
"nvim_plugin-folke/lazy.nvim": "nvim_plugin-folke/lazy.nvim"
"nvim_plugin-chrisgrieser/nvim-early-retirement": "nvim_plugin-chrisgrieser/nvim-early-retirement",
"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"
}
},
"systems": {

View file

@ -15,6 +15,31 @@
url = "github:catppuccin/nvim";
flake = false;
};
"nvim_plugin-Pocco81/auto-save.nvim" = {
url = "github:Pocco81/auto-save.nvim";
flake = false;
};
"nvim_plugin-chrisgrieser/nvim-early-retirement" = {
url = "github:chrisgrieser/nvim-early-retirement";
flake = false;
};
"nvim_plugin-MunifTanjim/nui.nvim" = {
url = "github:MunifTanjim/nui.nvim";
flake = false;
};
"nvim_plugin-rcarriga/nvim-notify" = {
url = "github:rcarriga/nvim-notify";
flake = false;
};
"nvim_plugin-folke/noice.nvim" = {
url = "github:folke/noice.nvim";
flake = false;
};
# TODO TELESCOPE
"nvim_plugin-declancm/cinnamon.nvim" = {
url = "github:declancm/cinnamon.nvim";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, ... } @ inputs:

View file

@ -47,6 +47,7 @@ function getSpec()
p.dir = NIX.pluginPaths[nixName]
p.name = p.name or p[1]
p.url = "not_used_in_nix"
p.pin = true
if p.dependencies then
p.dependencies = ensure_table(p.dependencies)
for i, dep in ipairs(p.dependencies) do
@ -62,7 +63,6 @@ function getSpec()
local plugin = string.sub(file, 0, -5)
table.insert(plugins, convertPluginToNixStore(require("plugins." .. plugin)))
end
print("PLUGINS" .. vim.inspect(plugins))
return plugins
else
-- TODO I want this to work in the nixos versionhttps://github.com/RingOfStorms/nvim/blob/nix-flake/init.lua#L39-L55
@ -78,10 +78,15 @@ require("lazy").setup({
enabled = false,
},
defaults = {
-- lazy = true
lazy = true,
},
})
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,3 +1,14 @@
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("config-highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank({ timeout = 300 })
end,
})
--function isEmpty()
--return vim.api.nvim_buf_get_name(0) == ""
--or vim.fn.filereadable(vim.api.nvim_buf_get_name(0)) == 0

View file

@ -1,3 +1,4 @@
local util = require("util")
-- Remap space as leader key
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
vim.g.mapleader = " "
@ -13,50 +14,54 @@ vim.g.maplocalleader = " "
local nvx = { "n", "v", "x" }
require("util").keymaps({
-- =============
-- n/v/x (normal + visual modes)
-- =============
util.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 },
{ "<down>", '<cmd>echo "use h/j/k/l to move!"<cr>', mode = nvx },
{ ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx },
{ "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx },
{ "<leader>w", "<cmd>w<cr>", desc = "Save", mode = nvx },
{
"<leader>q",
function()
-- Use to have this which always closed and quit ont he last screen: "<cmd>confirm q<cr>"
-- Instead I want this behavior:
-- if only 1 screen is open then close all buffers, resulting in a blank unnamed buffer window similar to fresh session
-- else if more than 1 screen, confirm q to close that screen
-- Check the number of screens
if vim.fn.winnr("$") == 1 then
-- If only 1 screen is open then close all buffers, resulting in a blank unnamed buffer window similar to fresh session
vim.cmd("bufdo bd")
vim.cmd("SessionDelete")
else
-- If more than 1 screen, confirm q to close that screen
vim.cmd("confirm q")
end
end,
desc = "Quit",
mode = nvx,
},
{ "Q", "<cmd>qa<CR>", desc = "Quit all", mode = nvx },
-- { "Q", "<cmd>qa<CR>", desc = "Quit all", mode = nvx },
{ "<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>y", '"+y', desc = "Copy to system clipboard", mode = nvx },
{ "<leader>p", '"+p', desc = "Paste from system clipboard", mode = nvx },
{ "<leader>bq", "<cmd>bp|bd #<cr>", desc = "Close current buffer only", mode = nvx },
{ "<leader>bn", "<cmd>enew<cr>", desc = "Open a new buffer in current screen", mode = nvx },
{ "<leader>bt", "<cmd>terminal<cr>i", desc = "Open a terminal in current screen", mode = nvx },
{ "<leader>tn", "<cmd>tabnew<cr>", desc = "Create new tab", mode = nvx },
{ "<leader>tq", "<cmd>tabclose<cr>", desc = "Close current tab", 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" },
-- Buffers
{ "<leader>b", "<cmd>b#<cr>", desc = "Switch to last buffer", mode = nvx },
{
"<leader>q",
function()
-- Custom close/quit
-- * if non empty buffer, we will simply open a new empty buffer unless
-- it is in the close always list
-- * if empty buffer, then we will quit this buffer
local close_always = { "quickfix", "help", "nofile" }
if
util.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")
else
vim.cmd("enew")
end
end,
desc = "Quit/Close current",
mode = nvx,
},
{
"<leader>S",
"<cmd>set equalalways<cr><cmd>set noequalalways<cr>",
@ -67,68 +72,60 @@ require("util").keymaps({
{ "<C-j>", "<C-W>j", desc = "Move window below current", mode = nvx },
{ "<C-k>", "<C-W>k", desc = "Move window above current", mode = nvx },
{ "<C-l>", "<C-W>l", desc = "Move window right current", mode = nvx },
{ "B", "<cmd>b#<cr>", desc = "Switch to last buffer", mode = nvx },
-- Tabs
-- TODO revisit, do I even need these tab things?
{ "<leader>tn", "<cmd>tabnew<cr>", desc = "Create new tab", mode = nvx },
{ "<leader>tq", "<cmd>tabclose<cr>", desc = "Close current tab", mode = nvx },
{ "H", "<cmd>tabprevious<cr>", desc = "Move to previous tab" },
{ "L", "<cmd>tabnext<cr>", desc = "Move to next tab" },
-- LSP/IDE/etc
{
"<leader>l<leader>",
function()
-- vim.cmd "SqlxFormat"
vim.lsp.buf.format()
end,
vim.lsp.buf.format,
desc = "Reformat file",
mode = nvx,
},
{
"<leader>ls<leader>",
"<cmd>SqlxFormat<cr>",
desc = "Format sqlx queries in rust raw string literals.",
mode = nvx,
},
{
"<leader>ld",
function()
vim.diagnostic.open_float()
end,
vim.diagnostic.open_float,
desc = "Show diagnostic message",
mode = nvx,
},
{
"<leader>ll",
function()
vim.diagnostic.setloclist()
end,
desc = "Show diagnostic list",
vim.diagnostic.setloclist,
desc = "Show diagnostics in quickfix list",
mode = nvx,
},
-- =============
-- =============
-- =============
-- =============
-- =============
-- =============
-- =============
-- normal mode
-- =============
-- { "", "", desc = "" },
{ "H", "<cmd>tabprevious<cr>", desc = "Move to previous tab" },
{ "L", "<cmd>tabnext<cr>", desc = "Move to next tab" },
{ "|", "<cmd>vsplit<cr>", desc = "Vertical Split" },
{ "\\", "<cmd>split<cr>", desc = "Horizontal Split" },
{ "n", "nzzzv", desc = "Next search result centered" },
{ "N", "Nzzzv", desc = "Previous search result centered" },
{ "<esc>", ":noh<CR><esc>", desc = "Clear search on escape" },
{ "<return>", ":noh<CR><return>", desc = "Clear search on return" },
{ "<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" },
-- { "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",
function()
vim.diagnostic.goto_next()
end,
desc = "Go to next diagnostic",
vim.diagnostic.goto_next,
desc = "Go to next diagnostic message",
},
{
"[d",
function()
vim.diagnostic.goto_prev()
end,
desc = "Go to next diagnostic",
vim.diagnostic.goto_prev,
desc = "Go to previous diagnostic message",
},
-- =============

View file

@ -1,12 +1,21 @@
-- allow use of system keyboard
-- vim.opt.clipboard = "unnamedplus"
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = true
-- global status line
vim.opt.laststatus = 3
-- Don't show the mode, since it's already in the status line
vim.opt.showmode = false
-- allow use of mouse
vim.opt.mouse = "a"
-- Decrease update time
vim.opt.updatetime = 250
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
vim.opt.timeoutlen = 300
-- line numbering, relative
vim.opt.number = true
vim.wo.number = true
@ -33,29 +42,45 @@ vim.opt.expandtab = true
-- Dont use swap files, use undotree
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undodir = vim.fn.stdpath("state") .. "/undodir"
vim.opt.undofile = true
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
vim.opt.list = true
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" }
-- TODO REVISIT IF I WANT THESE
-- Search settings
vim.opt.hlsearch = true
vim.opt.incsearch = true
-- Preview substitutions live, as you type
-- TODO revisit, what does this actually do
vim.opt.inccommand = "split"
-- Show which line your cursor is on
vim.opt.cursorline = true
-- split to the right or below always
vim.opt.splitbelow = true
vim.opt.splitright = true
-- Set completeopt to have a better completion experience
vim.o.completeopt = "menuone,noselect"
vim.opt.completeopt = "menuone,noselect"
vim.diagnostic.config({
float = { border = "single" },
})
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
-- Turn on new diff
vim.opt.diffopt:append("linematch:20")
-- Set screen mode
-- vim.o.noequalalways = true
-- vim.o.equalalways = false
-- Don't resize panels when closing something it is annoying
vim.opt.equalalways = false
-- enable colors for opacity changes
vim.o.termguicolors = true
vim.opt.termguicolors = true

View file

@ -0,0 +1,18 @@
return {
"Pocco81/auto-save.nvim",
event = "BufEnter",
opts = {
trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" },
condition = function(buf)
local disallowed_filetypes = { "TelescopePrompt", "quickfix", "terminal" }
local utils = require("auto-save.utils.data")
if
vim.fn.getbufvar(buf, "&modifiable") == 1
and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes)
then
return true
end
return false
end,
},
}

View file

@ -0,0 +1,10 @@
return {
"chrisgrieser/nvim-early-retirement",
config = true,
event = "VeryLazy",
opts = {
retirementAgeMins = 1,
notificationOnAutoClose = true,
-- deleteBufferWhenFileDeleted = true,
},
}

View file

@ -0,0 +1,32 @@
return {
"folke/noice.nvim",
event = "VeryLazy",
opts = {
cmdline = {
format = {
conceal = {
pattern = "^noh"
},
},
},
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, -- requires hrsh7th/nvim-cmp
},
},
},
config = function(_, opts)
require("noice").setup(opts)
end,
dependencies = {
-- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
"MunifTanjim/nui.nvim",
-- OPTIONAL:
-- `nvim-notify` is only needed, if you want to use the notification view.
-- If not available, we use `mini` as the fallback
"rcarriga/nvim-notify",
},
}

View file

@ -0,0 +1,27 @@
return {
"rcarriga/nvim-notify",
-- dependencies = { "nvim-telescope/telescope.nvim", optional = true },
lazy = false,
priority = 999,
opts = {
top_down = false,
timeout = 3000,
},
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,15 @@
return {
-- Smooth scrolling
"declancm/cinnamon.nvim",
event = "VeryLazy",
opts = {
extra_keymaps = true,
extended_keymaps = true,
-- override_keymaps = true,
max_length = 300,
default_delay = 2,
},
config = function(_, opts)
require("cinnamon").setup(opts)
end,
}

View file

@ -1,5 +1,8 @@
return {
"catppuccin/nvim",
-- load theme right away
lazy = false,
priority = 100,
opts = {
flavour = "mocha", -- latte, frappe, macchiato, mocha (default)
color_overrides = {