WIP on new config
This commit is contained in:
parent
c86f67f0f7
commit
c42f197307
13 changed files with 354 additions and 85 deletions
|
@ -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
|
||||
|
|
135
lua/keymaps.lua
135
lua/keymaps.lua
|
@ -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",
|
||||
},
|
||||
|
||||
-- =============
|
||||
|
|
|
@ -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
|
||||
|
|
18
lua/plugins/editor_auto_save.lua
Normal file
18
lua/plugins/editor_auto_save.lua
Normal 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,
|
||||
},
|
||||
}
|
10
lua/plugins/editor_earl_retirement.lua
Normal file
10
lua/plugins/editor_earl_retirement.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
return {
|
||||
"chrisgrieser/nvim-early-retirement",
|
||||
config = true,
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
retirementAgeMins = 1,
|
||||
notificationOnAutoClose = true,
|
||||
-- deleteBufferWhenFileDeleted = true,
|
||||
},
|
||||
}
|
32
lua/plugins/editor_noice.lua
Normal file
32
lua/plugins/editor_noice.lua
Normal 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",
|
||||
},
|
||||
}
|
27
lua/plugins/editor_notify.lua
Normal file
27
lua/plugins/editor_notify.lua
Normal 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,
|
||||
}
|
15
lua/plugins/editor_smooth_scroll.lua
Normal file
15
lua/plugins/editor_smooth_scroll.lua
Normal 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,
|
||||
}
|
|
@ -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 = {
|
Loading…
Add table
Add a link
Reference in a new issue