huge cleanup

This commit is contained in:
2025-02-22 17:46:00 -06:00
parent 4742d52e78
commit 74eb4c94b8
19 changed files with 136 additions and 275 deletions
-3
View File
@@ -1,4 +1 @@
packer_compiled.lua packer_compiled.lua
ftplugin/html.lua
ftplugin/json.lua
ftplugin/typescript.lua
-7
View File
@@ -1,7 +0,0 @@
--local helpers = require("helpers")
--local nmap = helpers.nmap
--
--nmap("]d", ":RustLsp renderDiagnostic<CR>")
----nmap("<Space>q", ":RustLsp explainError<CR>")
--nmap("<Space>q", ":RustLsp renderDiagnostic<CR>")
--nmap("<Space>f", ":RustFmt<CR>")
+2 -1
View File
@@ -1 +1,2 @@
require("helpers").set_tab(4) vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
+2 -1
View File
@@ -1 +1,2 @@
require("helpers").set_tab(4) vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
+2 -1
View File
@@ -1 +1,2 @@
require("helpers").set_tab(4) vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
+2 -1
View File
@@ -1 +1,2 @@
require("helpers").set_tab(2) vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
-1
View File
@@ -1 +0,0 @@
require("helpers").set_tab(4)
+14 -16
View File
@@ -1,20 +1,18 @@
local map = require("helpers").map local function map(mode, lhs, rhs)
vim.keymap.set(mode, lhs, rhs, { silent = true, noremap = true })
local function silent_map(mode, lhs, rhs)
map(mode, lhs, rhs, { silent = true })
end end
silent_map("n", "<Up>", "gk") map("n", "<Up>", "gk")
silent_map("n", "<Down>", "gj") map("n", "<Down>", "gj")
silent_map("n", "<Home>", "g<Home>") map("n", "<Home>", "g<Home>")
silent_map("n", "<End>", "g<End>") map("n", "<End>", "g<End>")
silent_map("v", "<Up>", "gk") map("v", "<Up>", "gk")
silent_map("v", "<Down>", "gj") map("v", "<Down>", "gj")
silent_map("v", "<Home>", "g<Home>") map("v", "<Home>", "g<Home>")
silent_map("v", "<End>", "g<End>") map("v", "<End>", "g<End>")
silent_map("i", "<Up>", "<C-o>gk") map("i", "<Up>", "<C-o>gk")
silent_map("i", "<Down>", "<C-o>gj") map("i", "<Down>", "<C-o>gj")
silent_map("i", "<Home>", "<C-o>g<Home>") map("i", "<Home>", "<C-o>g<Home>")
silent_map("i", "<End>", "<C-o>g<End>") map("i", "<End>", "<C-o>g<End>")
+2 -1
View File
@@ -1 +1,2 @@
require("helpers").set_tab(4) vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
-1
View File
@@ -1 +0,0 @@
require("helpers").set_tab(4)
+1 -2
View File
@@ -1,7 +1,6 @@
require("base") require("base")
if (not vim.g.vscode) and os.getenv("NO_PLUGINS") == nil then if (not vim.g.vscode) and os.getenv("NO_PLUGINS") == nil then
require("specifics")
require("plugins") require("plugins")
require("buffer_tools").init() require("buffer_tools")
end end
+7 -26
View File
@@ -6,24 +6,20 @@ local function map(mode, lhs, rhs, opts)
if opts then if opts then
default_opts = vim.tbl_extend("force", default_opts, opts) default_opts = vim.tbl_extend("force", default_opts, opts)
end end
--vim.api.nvim_set_keymap(mode, lhs, rhs, default_opts)
vim.keymap.set(mode, lhs, rhs, default_opts) vim.keymap.set(mode, lhs, rhs, default_opts)
end end
local function silent_map(mode, lhs, rhs)
map(mode, lhs, rhs, { silent = true })
end
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
g.mapleader = "," g.mapleader = ","
-- Move cursor relative to visual line breaks
local function silent_map(mode, lhs, rhs)
map(mode, lhs, rhs, { silent = true })
end
silent_map("v", "<C-C>", '"+y') silent_map("v", "<C-C>", '"+y')
silent_map("n", "<Esc>", ":noh<CR><Esc>") --After searching, pressing escape stops the highlight silent_map("n", "<Esc>", ":noh<CR><Esc>") --After searching, pressing escape stops the highlight
--silent_map("n", "<Tab>", ":bnext<CR>")
--silent_map("n", "<S-Tab>", ":bprevious<CR>")
map("n", "<Leader>w", [[:%s/\s\+$//e<CR>]]) map("n", "<Leader>w", [[:%s/\s\+$//e<CR>]])
map("n", "<Leader>x", ":bp|bd #<CR>") map("n", "<Leader>x", ":bp|bd #<CR>")
@@ -58,13 +54,6 @@ map("i", "<S-Down>", "<C-X><C-E>")
-- Make visual yanks place the cursor back where started -- Make visual yanks place the cursor back where started
map("v", "y", "ygv<Esc>") map("v", "y", "ygv<Esc>")
-- Terminal binds
--local term_command = "split | set norelativenumber | set nonumber | term"
local term_command = "split | term"
map("t", "<C-Space>", [[<C-\><C-n>]])
map("n", [[<Leader>\]], ":" .. term_command .. "<CR>")
map("n", [[<Leader>|]], ":v" .. term_command .. "<CR>")
-- line-break movement -- line-break movement
--silent_map("n", "<Up>", "gk") --silent_map("n", "<Up>", "gk")
--silent_map("n", "<Down>", "gj") --silent_map("n", "<Down>", "gj")
@@ -81,14 +70,6 @@ map("n", [[<Leader>|]], ":v" .. term_command .. "<CR>")
--silent_map("i", "<Home>", "<C-o>g<Home>") --silent_map("i", "<Home>", "<C-o>g<Home>")
--silent_map("i", "<End>", "<C-o>g<End>") --silent_map("i", "<End>", "<C-o>g<End>")
-- half page movement
--silent_map("n", "<PageDown>", "M<C-d>")
--silent_map("n", "<PageUp>", "M<C-u>")
--silent_map("v", "<PageDown>", "M<C-d>")
--silent_map("v", "<PageUp>", "M<C-u>")
--silent_map("i", "<PageDown>", "<C-o>M<C-o><C-d>")
--silent_map("i", "<PageUp>", "<C-o>M<C-o><C-u>")
-- half page movement, primeagen version -- half page movement, primeagen version
silent_map("n", "<PageDown>", "<C-d>zz") silent_map("n", "<PageDown>", "<C-d>zz")
silent_map("n", "<PageUp>", "<C-u>zz") silent_map("n", "<PageUp>", "<C-u>zz")
@@ -97,9 +78,9 @@ silent_map("v", "<PageUp>", "<C-u>zz")
silent_map("i", "<PageDown>", "<C-o><C-d><C-o>zz") silent_map("i", "<PageDown>", "<C-o><C-d><C-o>zz")
silent_map("i", "<PageUp>", "<C-o><C-u><C-o>zz") silent_map("i", "<PageUp>", "<C-o><C-u><C-o>zz")
-- dynamic tab -- tab buffer movement
silent_map("n", "<Tab>", ":lua require('dynamic_tab').tab()<CR>") silent_map("n", "<Tab>", ":bnext<CR>")
silent_map("n", "<S-Tab>", ":lua require('dynamic_tab').shift_tab()<CR>") silent_map("n", "<S-Tab>", ":bprevious<CR>")
opt.autoindent = true opt.autoindent = true
opt.autoread = true opt.autoread = true
+2 -9
View File
@@ -1,5 +1,3 @@
local M = {}
local function get_active_buffers() local function get_active_buffers()
local active_buffers = {} local active_buffers = {}
for tabnr = 1, vim.fn.tabpagenr("$") do for tabnr = 1, vim.fn.tabpagenr("$") do
@@ -20,7 +18,7 @@ local function get_all_buffers()
return all_buffers return all_buffers
end end
function M.remove_unused_buffers() local function remove_unused_buffers()
local active_buffers = get_active_buffers() local active_buffers = get_active_buffers()
local all_buffers = get_all_buffers() local all_buffers = get_all_buffers()
local buffers_to_remove = {} local buffers_to_remove = {}
@@ -36,9 +34,4 @@ function M.remove_unused_buffers()
end end
end end
function M.init() vim.keymap.set("n", "<Leader>b", remove_unused_buffers, { noremap = true })
local map = require("helpers").map
map("n", "<Leader>b", ":lua require('buffer_tools').remove_unused_buffers()<CR>")
end
return M
-16
View File
@@ -1,16 +0,0 @@
local M = {}
-- Whether to switch between buffers or tabs
function M.tab_mode()
return vim.fn.tabpagenr("$") > 1
end
function M.tab()
vim.cmd(M.tab_mode() and "tabn" or "bnext")
end
function M.shift_tab()
vim.cmd(M.tab_mode() and "tabp" or "bprevious")
end
return M
-8
View File
@@ -1,8 +0,0 @@
local M = {}
function M.cwd()
local path = vim.fn.expand("%:p:h")
vim.cmd("Files " .. path)
end
return M
-19
View File
@@ -1,19 +0,0 @@
local M = {}
-- Grabbed from harpoon code
function M.get_marked_files()
local Marked = require("harpoon.mark")
local contents = {}
for idx = 1, Marked.get_length() do
local file = Marked.get_marked_file_name(idx)
if file == "" then
file = "(empty)"
end
contents[idx] = string.format("%s", file)
end
return contents
end
return M
-82
View File
@@ -1,82 +0,0 @@
local M = {}
function M.map(mode, lhs, rhs, opts)
local default_opts = { noremap = true }
if opts then
default_opts = vim.tbl_extend("force", default_opts, opts)
end
--vim.api.nvim_set_keymap(mode, lhs, rhs, default_opts)
vim.keymap.set(mode, lhs, rhs, default_opts)
end
function M.nmap(...)
M.map("n", ...)
end
function M.lsp_config_defaults()
return {
root_dir = require("lspconfig.util").root_pattern(
"pyproject.toml",
"package.json",
".null-ls-root",
".git"
),
on_attach = function(client, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
---- Disables document formatting by lsp
--client.resolved_capabilities.document_formatting = false
--client.resolved_capabilities.document_range_formatting = false
-- Enable completion triggered by <c-x><c-o>
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
local opts = { noremap = true, silent = true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
buf_set_keymap("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
buf_set_keymap(
"n",
"<space>wl",
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>",
opts
)
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
buf_set_keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev({wrap = true})<CR>", opts)
buf_set_keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next({wrap = true})<CR>", opts)
buf_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
local version = vim.version()
if version.api_level == 9 then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
else
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.format({ async = true })<CR>", opts)
end
end,
}
end
function M.set_tab(length)
vim.bo.shiftwidth = length
vim.bo.tabstop = length
end
return M
+77 -52
View File
@@ -1,11 +1,57 @@
local helpers = require("helpers") local function map(mode, lhs, rhs, opts)
local map = helpers.map local default_opts = { noremap = true }
local lsp_config_defaults = helpers.lsp_config_defaults if opts then
default_opts = vim.tbl_extend("force", default_opts, opts)
end
vim.keymap.set(mode, lhs, rhs, default_opts)
end
local function silent_map(mode, lhs, rhs)
map(mode, lhs, rhs, { silent = true })
end
local function nmap(...) local function nmap(...)
map("n", ...) map("n", ...)
end end
local function lsp_config_defaults()
return {
root_dir = require("lspconfig.util").root_pattern("pyproject.toml", "package.json", ".null-ls-root", ".git"),
on_attach = function(_, bufnr)
vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr })
local opts = { noremap = true, silent = true, buffer = bufnr }
nmap("<C-k>", vim.lsp.buf.signature_help, opts)
nmap("<space>D", vim.lsp.buf.type_definition, opts)
nmap("<space>ca", vim.lsp.buf.code_action, opts)
nmap("<space>e", vim.diagnostic.open_float, opts)
nmap("<space>q", vim.diagnostic.setloclist, opts)
nmap("<space>rn", vim.lsp.buf.rename, opts)
nmap("<space>wa", vim.lsp.buf.add_workspace_folder, opts)
nmap("<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
nmap("<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
nmap("K", vim.lsp.buf.hover, opts)
nmap("[d", function()
vim.diagnostic.goto_prev({ wrap = true })
end, opts)
nmap("]d", function()
vim.diagnostic.goto_next({ wrap = true })
end, opts)
nmap("gD", vim.lsp.buf.declaration, opts)
nmap("gd", vim.lsp.buf.definition, opts)
nmap("gi", vim.lsp.buf.implementation, opts)
nmap("gr", vim.lsp.buf.references, opts)
nmap("<space>f", function()
vim.lsp.buf.format({ async = true })
end, opts)
end,
}
end
local M = {} local M = {}
function M.hop() function M.hop()
@@ -22,6 +68,11 @@ function M.hop()
end end
function M.fzf() function M.fzf()
local function cwd()
local path = vim.fn.expand("%:p:h")
vim.cmd("Files " .. path)
end
map("n", "<Leader>o", ":Files<CR>") map("n", "<Leader>o", ":Files<CR>")
map("n", "<Leader>O", ":Files ~/<CR>") map("n", "<Leader>O", ":Files ~/<CR>")
map("n", "<Leader>p", ":Buffers<CR>") map("n", "<Leader>p", ":Buffers<CR>")
@@ -34,11 +85,7 @@ function M.fzf()
map("n", "<Leader>gl", ":GFiles<CR>") map("n", "<Leader>gl", ":GFiles<CR>")
map("n", "<Leader>gs", ":GFiles?<CR>") map("n", "<Leader>gs", ":GFiles?<CR>")
map("n", "<Leader>gc", ":Commits<CR>") map("n", "<Leader>gc", ":Commits<CR>")
--map("n", "<Leader>l", ":lua require('fzf_funcs').cwd()<CR>") map("n", "<Leader>l", cwd)
--map("n", "<Leader>f", ":lua require('fzf_funcs').cwd()<CR>")
local fzf = require("fzf_funcs")
map("n", "<Leader>l", fzf.cwd)
end end
function M.fzf_checkout() function M.fzf_checkout()
@@ -82,15 +129,11 @@ function M.auto_session()
auto_session_suppress_dirs = { "~/", "~/Projects" }, auto_session_suppress_dirs = { "~/", "~/Projects" },
auto_session_use_git_branch = true, auto_session_use_git_branch = true,
}) })
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
end end
function M.indent_blankline() function M.indent_blankline()
--vim.opt.list = true
--require("indent_blankline").setup({
-- space_char_blankline = " ",
-- show_current_context = true,
-- show_current_context_start = true,
--})
require("ibl").setup() require("ibl").setup()
end end
@@ -100,6 +143,22 @@ function M.lualine()
return vim.o.columns * num / 6 return vim.o.columns * num / 6
end end
local function tab_mode()
return vim.fn.tabpagenr("$") > 1
end
local function tab()
vim.cmd(tab_mode() and "tabn" or "bnext")
end
local function shift_tab()
vim.cmd(tab_mode() and "tabp" or "bprevious")
end
-- dynamic tab
silent_map("n", "<Tab>", tab)
silent_map("n", "<S-Tab>", shift_tab)
-- config options -- config options
local function buffer_window(type, cond) local function buffer_window(type, cond)
return { return {
@@ -158,7 +217,7 @@ function M.lualine()
{ {
"tabs", "tabs",
cond = function() cond = function()
return require("dynamic_tab").tab_mode() return tab_mode()
end, end,
max_length = function() max_length = function()
return columns(1) return columns(1)
@@ -167,10 +226,10 @@ function M.lualine()
}, },
lualine_b = { lualine_b = {
buffer_window("windows", function() buffer_window("windows", function()
return require("dynamic_tab").tab_mode() return tab_mode()
end), end),
buffer_window("buffers", function() buffer_window("buffers", function()
return not require("dynamic_tab").tab_mode() return not tab_mode()
end), end),
}, },
lualine_c = {}, lualine_c = {},
@@ -458,41 +517,7 @@ end
function M.rustaceanvim() function M.rustaceanvim()
vim.g.rustaceanvim = { vim.g.rustaceanvim = {
server = { server = {
on_attach = function(client, bufnr) on_attach = lsp_config_defaults().on_attach,
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local opts = { noremap = true, silent = true }
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
buf_set_keymap("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
buf_set_keymap(
"n",
"<space>wl",
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>",
opts
)
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
buf_set_keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev({wrap = true})<CR>", opts)
buf_set_keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next({wrap = true})<CR>", opts)
buf_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
if vim.version().api_level == 9 then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
else
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.format({ async = true })<CR>", opts)
end
end,
}, },
} }
end end
-3
View File
@@ -1,3 +0,0 @@
local g = vim.g
g.python3_host_prog = "/usr/bin/python3"