several small updates

This commit is contained in:
RingOfStorms (Joshua Bell) 2024-05-02 23:51:15 -05:00
parent 545b3d492f
commit b0c61768db
9 changed files with 432 additions and 415 deletions

View file

@ -13,112 +13,117 @@ vim.g.maplocalleader = " "
local nvx = { "n", "v", "x" }
-- TODO remove this notify and replace with a <nop> once I have trained well enough
local hjklNotid = nil
local hjklNotification = function()
hjklNotid = vim.notify("use h/j/k/l to move", 4, { replace = hjklNotid })
end
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 },
{ "<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>Q", "<nop>", mode = nvx }, -- don't do normal Q quit
{ "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx },
{ "Q", "<cmd>SessionSave<cr><cmd>qa!<cr>", desc = "Quit all", 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" },
-- Basic
{ "<left>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ "<right>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ "<up>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ "<down>", hjklNotification, mode = { "n", "v", "x", "i" } },
{ ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx },
{ "<leader>Q", "<nop>", mode = nvx }, -- don't do normal Q quit
{ "<leader>a", "<esc>ggVG", desc = "Select all", mode = nvx },
{ "Q", "<cmd>SessionSave<cr><cmd>qa!<cr>", desc = "Quit all", 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 },
{
"<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", "noice", "httpResult" }
if
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")
else
vim.cmd("enew")
end
end,
desc = "Quit/Close current",
mode = nvx,
},
{
"<leader>S",
"<cmd>set equalalways<cr><cmd>set noequalalways<cr>",
desc = "Equalize/resize screens evenly",
mode = nvx,
},
{ "<C-h>", "<C-W>h", desc = "Move window left current", mode = nvx },
{ "<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 },
-- 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", "noice", "httpResult" }
if
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")
else
vim.cmd("enew")
end
end,
desc = "Quit/Close current",
mode = nvx,
},
{
"<leader>S",
"<cmd>set equalalways<cr><cmd>set noequalalways<cr>",
desc = "Equalize/resize screens evenly",
mode = nvx,
},
{ "<C-h>", "<C-W>h", desc = "Move window left current", mode = nvx },
{ "<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 },
-- 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" },
-- 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>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-j>", "<Down>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-h>", "<Left>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-l>", "<Right>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-4>", "<End>", mode = { "i", "c" }, desc = "Movements in insert/command mode" },
{ "<C-6>", "<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 },
{ "<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" },
-- 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 TODO move to lsp config file
{
"<leader>ld",
vim.diagnostic.open_float,
desc = "Show diagnostic message",
mode = nvx,
},
{
"<leader>ll",
vim.diagnostic.setloclist,
desc = "Show diagnostics in quickfix list",
mode = nvx,
},
-- LSP/IDE/etc TODO move to lsp config file
{
"<leader>ld",
vim.diagnostic.open_float,
desc = "Show diagnostic message",
mode = nvx,
},
{
"<leader>ll",
vim.diagnostic.setloclist,
desc = "Show diagnostics in quickfix list",
mode = nvx,
},
})

View file

@ -70,6 +70,7 @@ return {
-- completions whenever it has completion options available.
["<C-c>"] = cmp.mapping.complete({}),
-- TODO remove these or make them soemthing else, this collided with my normal movements in insert mode
-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
@ -78,16 +79,16 @@ return {
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { "i", "s" }),
["<C-h>"] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { "i", "s" }),
-- ["<C-l>"] = cmp.mapping(function()
-- if luasnip.expand_or_locally_jumpable() then
-- luasnip.expand_or_jump()
-- end
-- end, { "i", "s" }),
-- ["<C-h>"] = cmp.mapping(function()
-- if luasnip.locally_jumpable(-1) then
-- luasnip.jump(-1)
-- end
-- end, { "i", "s" }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps

View file

@ -1,36 +1,37 @@
return {
"folke/noice.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
{ "nvim-telescope/telescope.nvim", optional = true },
},
event = "VeryLazy",
opts = {
routes = {
-- I want telescope-ui-select to trigger here not noice
{ filter = { event = "lsp", kind = "search_count" }, opts = { skip = true } },
},
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**
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)
U.safeRequire("telescope", function(t)
t.load_extension("noice")
end)
end,
"folke/noice.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
{ "nvim-telescope/telescope.nvim", optional = true },
},
event = "VeryLazy",
opts = {
routes = {
-- I want telescope-ui-select to trigger here not noice
{ filter = { event = "lsp", kind = "search_count" }, opts = { skip = true } },
{ filter = { event = "lsp" }, opts = { skip = true } }, -- TODO come back to this, im having weird issues with insert mode getting broken.
},
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**
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)
U.safeRequire("telescope", function(t)
t.load_extension("noice")
end)
end,
}

View file

@ -1,30 +1,38 @@
return {
"stevearc/conform.nvim",
opts = {
-- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup
notify_on_error = true,
formatters_by_ft = {
lua = { "stylua" },
typescript = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
javascript = { { "prettierd", "prettier" } },
javascriptreact = { { "prettierd", "prettier" } },
},
},
keys = {
{
"<leader>l<leader>",
function()
require("conform").format({ async = true, lsp_fallback = true }, function(err, edited)
if edited then
print("Formatted!")
else
print("Nothing to format!")
end
end)
end,
mode = { "n", "v", "x" },
desc = "Format buffer",
},
},
"stevearc/conform.nvim",
opts = {
-- https://github.com/stevearc/conform.nvim?tab=readme-ov-file#setup
notify_on_error = true,
-- Note that all these need to be available at runtime, add them to flake.nix#runtimeDependencies
formatters_by_ft = {
lua = { "stylua" },
nix = { "nixfmt" },
typescript = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
javascript = { { "prettierd", "prettier" } },
javascriptreact = { { "prettierd", "prettier" } },
-- TODO revisit these I'd like to use them but they are not in nixpkgs yet
-- https://nixos.org/guides/nix-pills/
-- markdown = { "mdslw", "mdsf"},
markdown = { "markdownlint-cli2" },
},
},
keys = {
{
"<leader>l<leader>",
function()
require("conform").format({ async = true, lsp_fallback = true }, function(err, edited)
if edited then
print("Formatted!")
elseif err then
print(err)
else
print("Nothing to format!")
end
end)
end,
mode = { "n", "v", "x" },
desc = "Format buffer",
},
},
}

View file

@ -1,163 +1,169 @@
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")
"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",
["<C-h>"] = false,
["<C-l>"] = false,
["<up>"] = false,
["<down>"] = false,
["<left>"] = false,
["<right>"] = false,
},
},
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>f/",
function()
require("telescope.builtin").current_buffer_fuzzy_find(
require("telescope.themes").get_dropdown({ winblend = 10, previewer = false })
)
end,
desc = "Fuzzy find/search in current buffer fuzzy.",
},
{
"<leader>fh",
function()
require("telescope.builtin").help_tags()
end,
desc = "Find help",
},
{
"<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 Keymap",
},
{
"<leader>fb",
function()
require("telescope.builtin").buffers()
end,
desc = "Find Buffer",
},
{
"<leader>lfr",
function()
require("telescope.builtin").lsp_references()
end,
desc = "Find LSP References",
mode = { "n", "v", "x" },
},
},
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>f/",
function()
require("telescope.builtin").current_buffer_fuzzy_find(
require("telescope.themes").get_dropdown({ winblend = 10, previewer = false })
)
end,
desc = "Fuzzy find/search in current buffer fuzzy.",
},
{
"<leader>fh",
function()
require("telescope.builtin").help_tags()
end,
desc = "Find help",
},
{
"<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 Keymap",
},
{
"<leader>fb",
function()
require("telescope.builtin").buffers()
end,
desc = "Find Buffer",
},
{
"<leader>lfr",
function()
require("telescope.builtin").lsp_references()
end,
desc = "Find LSP References",
mode = { "n", "v", "x" },
},
},
}

View file

@ -10,7 +10,7 @@ return {
{
"<leader>,c",
function()
if next(vim.lsp.buf_get_clients()) ~= nil then
if next(vim.lsp.get_active_clients()) ~= nil then
-- TODO test that this works
vim.cmd("TextCaseOpenTelescopeLSPChange")
else
@ -19,7 +19,6 @@ return {
end,
desc = "Change case of selection",
mode = { "n", "v", "x" },
silent = true, -- TODO add this to most things....
},
},
}