chore: Remove neovim clutter

This commit is contained in:
Fabio Lenherr / DashieTM 2023-11-18 00:42:20 +01:00
commit af4dc010b8
10 changed files with 89 additions and 540 deletions

View file

@ -17,45 +17,3 @@ vim.api.nvim_create_autocmd("LspAttach", {
end
end,
})
local modifiedBufs = function(bufs)
local t = 0
for _, v in pairs(bufs) do
if v.name:match("NvimTree_") == nil then
t = t + 1
end
end
return t
end
vim.api.nvim_create_autocmd("BufEnter", {
nested = true,
callback = function()
if
#vim.api.nvim_list_wins() == 1
and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil
and modifiedBufs(vim.fn.getbufinfo({ bufmodified = 1 })) == 0
then
vim.cmd("quit")
end
end,
})
local function open_nvim_tree(data)
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
if not directory then
return
end
-- change to the directory
if directory then
vim.cmd.cd(data.file)
end
-- open the tree
require("nvim-tree.api").tree.open()
end
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })

View file

@ -43,11 +43,6 @@ map("i", "<A-j>", [[<Cmd>wincmd h<CR>]], opts)
map("i", "<A-;>", [[<Cmd>wincmd l<CR>]], opts)
map("i", "<A-k>", [[<Cmd>wincmd j<CR>]], opts)
-- file tree
map("n", "<A-f>", function()
require("nvim-tree.api").tree.toggle()
end, opts)
-- toggle terminal
local lazyterm = function()
Util.terminal(nil, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false })
@ -142,6 +137,11 @@ require("neoscroll.config").set_mappings(t)
-- trouble
map("n", "<leader>t", "<cmd>TroubleToggle<CR>", term_opts)
-- format
map({ "n", "v" }, "<F4>", function()
Util.format({ force = true })
end, { desc = "Format" })
-- better yank
function Better_yank(opts)
local current_line = unpack(vim.api.nvim_win_get_cursor(0))

View file

@ -1,15 +1,18 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable",
lazypath })
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.java" },
@ -26,32 +29,18 @@ require("lazy").setup({
{ import = "lazyvim.plugins.extras.ui.alpha" },
{ import = "plugins" },
{ import = "plugins.plugins" },
-- import any extras modules here
-- { import = "lazyvim.plugins.extras.lang.typescript" },
-- { import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
-- import/override with your plugins
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
lazy = true,
version = false,
},
install = { colorscheme = { "tokyonight", "catppuccin-mocha" } },
checker = { enabled = true, notify = false },
change_detection = { enabled = true, notify = false }, --know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
change_detection = { enabled = true, notify = false },
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",

View file

@ -15,7 +15,7 @@ function M.get()
{ "<leader>cl", "<cmd>LspInfo<cr>", desc = "Lsp Info" },
{ "<leader>ca", "<cmd>Telescope lsp_definitions<cr>", desc = "Goto Definition", has = "definition" },
{ "<leader>cs", "<cmd>Telescope lsp_references<cr>", desc = "References" },
{ "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" },
{ "<leader>cA", vim.lsp.buf.declaration, desc = "Goto Declaration" },
{ "<leader>cf", "<cmd>Telescope lsp_implementations<cr>", desc = "Goto Implementation" },
{ "<leader>cd", "<cmd>Telescope lsp_type_definitions<cr>", desc = "Goto Type Definition" },
{ "<leader>ce", vim.lsp.buf.hover, desc = "Hover" },
@ -27,8 +27,8 @@ function M.get()
{ "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" },
{ "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" },
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
{ "<F4>", format, desc = "Format Document", has = "formatting" },
-- { "<leader>cf", format, desc = "Format Range", mode = "v", has = "documentRangeFormatting" },
{ "<F4>", format, desc = "Format Range", mode = "v", has = "documentRangeFormatting" },
{ "<leader>cr", ":IncRename ", desc = "FUCK", has = "rename" },
{
"<leader>cq",
function()
@ -68,20 +68,6 @@ function M.get()
has = "codeAction",
},
}
if require("lazyvim.util").has("inc-rename.nvim") then
M._keys[#M._keys + 1] = {
"<leader>cr",
function()
require("inc_rename")
return ":IncRename " .. vim.fn.expand("<cword>")
end,
expr = true,
desc = "Rename",
has = "rename",
}
else
M._keys[#M._keys + 1] = { "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }
end
end
return M._keys
end

View file

@ -1,301 +0,0 @@
return {
{
"rcarriga/nvim-dap-ui",
keys = {},
opts = {},
config = function(_, opts)
local dap = require("dap")
local dapui = require("dapui")
dapui.setup(opts)
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close({})
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close({})
end
end,
},
{
"mfussenegger/nvim-dap",
lazy = true,
dependencies = {
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
{
"jay-babu/mason-nvim-dap.nvim",
opts = {
ensure_installed = {
"node2",
"python",
"javadbg",
"javatest",
"codelldb",
"firefox",
"bash",
"delve",
"coreclr",
},
automatic_installation = true,
automatic_setup = true,
},
config = function(_, opts)
require("mason-nvim-dap").setup(opts)
-- require("mason-nvim-dap").setup_handlers({
-- javadbg = function() end,
-- })
end,
},
},
config = function()
local dap = require("dap")
dap.adapters.lldb = {
type = "executable",
command = "/usr/bin/lldb-vscode",
name = "lldb",
}
dap.adapters.nlua = function(callback, config)
callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 })
end
dap.adapters.bashdb = {
type = "executable",
command = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/bash-debug-adapter",
name = "bashdb",
}
dap.adapters.coreclr = {
type = "executable",
command = "netcoredbg",
args = { "--interpreter=vscode" },
}
-- local rust_dap = Get_git_root().cwd
-- local filename = ""
-- for w in rust_dap:gmatch("([^/]+)") do
-- filename = w
-- end
-- filename = filename:gsub("-", "_")
-- filename = string.lower(filename)
-- dap.configurations.rust = {
-- {
-- type = "lldb",
-- request = "launch",
-- program = function()
-- return rust_dap .. "/target/debug/" .. filename
-- end,
-- --program = '${fileDirname}/${fileBasenameNoExtension}',
-- cwd = "${workspaceFolder}",
-- terminal = "integrated",
-- initCommands = function()
-- -- Find out where to look for the pretty printer Python module
-- local rustc_sysroot = vim.fn.trim(vim.fn.system("rustc --print sysroot"))
--
-- local script_import = 'command script import "' .. rustc_sysroot .. '/lib/rustlib/etc/lldb_lookup.py"'
-- local commands_file = rustc_sysroot .. "/lib/rustlib/etc/lldb_commands"
--
-- local commands = {}
-- local file = io.open(commands_file, "r")
-- if file then
-- for line in file:lines() do
-- table.insert(commands, line)
-- end
-- file:close()
-- end
-- table.insert(commands, 1, script_import)
--
-- return commands
-- end,
-- },
-- }
dap.configurations.cpp = {
{
name = "debug cpp",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", Get_git_root().cwd .. "/build/", "file")
end,
cwd = "${workspaceFolder}",
terminal = "integrated",
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.python = {
{
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
request = "launch",
name = "Launch file",
program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
return cwd .. "/venv/bin/python"
elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
return cwd .. "/.venv/bin/python"
else
return "/usr/bin/python"
end
end,
},
}
dap.configurations.java = {
{
request = "attach",
name = "Debug (Attach) - Remote",
hostName = "127.0.0.1",
port = 5005,
},
}
dap.configurations.go = {
{
type = "delve",
name = "Debug",
request = "launch",
program = "${file}",
},
{
type = "delve",
name = "Debug test", -- configuration for debugging test files
request = "launch",
mode = "test",
program = "${file}",
},
{
type = "delve",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}",
},
}
dap.configurations.javascript = {
{
name = "Launch",
type = "js",
request = "launch",
program = "${file}",
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = "inspector",
console = "integratedTerminal",
},
}
dap.configurations.typescript = {
{
name = "Debug with Firefox",
type = "firefox",
request = "launch",
reAttach = true,
url = "http://localhost:3000",
webRoot = "${workspaceFolder}",
firefoxExecutable = "/usr/bin/firefox",
},
}
dap.configurations.lua = {
{
type = "nlua",
request = "attach",
name = "Attach to running Neovim instance",
},
}
dap.configurations.cs = {
{
type = "coreclr",
name = "launch - netcoredbg",
request = "launch",
program = function()
return vim.fn.input("Path to dll: ", Get_git_root().cwd, "file")
end,
-- args = function()
-- vim.fn.input("args: ", Get_git_root().cwd, "file")
-- end,
},
}
dap.configurations.sh = {
{
type = "bashdb",
request = "launch",
name = "Launch file",
showDebugOutput = true,
pathBashdb = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb",
pathBashdbLib = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir",
trace = true,
file = "${file}",
program = "${file}",
cwd = "${workspaceFolder}",
pathCat = "cat",
pathBash = "/bin/bash",
pathMkfifo = "mkfifo",
pathPkill = "pkill",
args = {},
env = {},
terminalKind = "integrated",
},
}
require("dapui").setup({
icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" },
mappings = {
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
expand_lines = vim.fn.has("nvim-0.7") == 1,
layouts = {
{
elements = {
{ id = "scopes", size = 0.25 },
"breakpoints",
"stacks",
"watches",
},
size = 40, -- 40 columns
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 0.25, -- 25% of total lines
position = "bottom",
},
},
controls = {
enabled = true,
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "↻",
terminate = "□",
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
},
})
require("nvim-dap-virtual-text").setup()
end,
},
}

View file

@ -1,7 +1,4 @@
return {
{
{ "nvim-neo-tree/neo-tree.nvim", enabled = false },
},
{
{ "rcarriga/nvim-notify", enabled = false },
},

View file

@ -146,7 +146,6 @@ return {
opencl_ls = {},
yamlls = {},
lua_ls = {
-- mason = false, -- set to false if you don't want this server to be installed with mason
settings = {
Lua = {
workspace = {
@ -165,35 +164,28 @@ return {
end,
},
},
setup = function(_, _)
local Util = require("lazyvim.util")
Util.lsp.on_attach(function(client, buffer)
require("config.lsp-keymap").on_attach(client, buffer)
end)
vim.cmd([[highlight LspInlayHint guibg=#1A1B26]])
init = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
local my_keys = require("config.lsp-keymap").get()
local count = 0
for _ in pairs(my_keys) do
keys[#keys + 1] = my_keys[count]
count = count + 1
end
end,
},
{
"DashieTM/null.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "mason.nvim" },
"stevearc/conform.nvim",
opts = function()
local nls = require("null-ls")
return {
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
sources = {
nls.builtins.formatting.fish_indent,
nls.builtins.diagnostics.fish,
nls.builtins.formatting.stylua,
nls.builtins.formatting.shfmt,
nls.builtins.diagnostics.flake8,
nls.builtins.formatting.autopep8,
nls.builtins.formatting.prettierd,
nls.builtins.formatting.typst,
local opts = {
formatters_by_ft = {
lua = { "stylua" },
fish = { "fish_indent" },
sh = { "shfmt" },
typst = { "typstfmt" },
},
}
return opts
end,
},
}

View file

@ -1,104 +0,0 @@
return {
{
"nvim-tree/nvim-tree.lua",
lazy = true,
opts = {
on_attach = function(bufnr)
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
vim.keymap.set("n", "<C-]>", api.tree.change_root_to_node, opts("CD"))
vim.keymap.set("n", "<C-e>", api.node.open.replace_tree_buffer, opts("Open: In Place"))
vim.keymap.set("n", "<C-k>", api.node.show_info_popup, opts("Info"))
vim.keymap.set("n", "<C-r>", api.fs.rename_sub, opts("Rename: Omit Filename"))
vim.keymap.set("n", "<C-t>", api.node.open.tab, opts("Open: New Tab"))
vim.keymap.set("n", "<C-v>", api.node.open.vertical, opts("Open: Vertical Split"))
vim.keymap.set("n", "<C-x>", api.node.open.horizontal, opts("Open: Horizontal Split"))
vim.keymap.set("n", "<BS>", api.node.navigate.parent_close, opts("Close Directory"))
vim.keymap.set("n", "<CR>", api.node.open.edit, opts("Open"))
vim.keymap.set("n", "<Tab>", api.node.open.preview, opts("Open Preview"))
vim.keymap.set("n", ">", api.node.navigate.sibling.next, opts("Next Sibling"))
vim.keymap.set("n", "<", api.node.navigate.sibling.prev, opts("Previous Sibling"))
vim.keymap.set("n", ".", api.node.run.cmd, opts("Run Command"))
vim.keymap.set("n", "-", api.tree.change_root_to_parent, opts("Up"))
vim.keymap.set("n", "a", api.fs.create, opts("Create"))
vim.keymap.set("n", "bmv", api.marks.bulk.move, opts("Move Bookmarked"))
vim.keymap.set("n", "B", api.tree.toggle_no_buffer_filter, opts("Toggle No Buffer"))
vim.keymap.set("n", "c", api.fs.copy.node, opts("Copy"))
vim.keymap.set("n", "C", api.tree.toggle_git_clean_filter, opts("Toggle Git Clean"))
vim.keymap.set("n", "[c", api.node.navigate.git.prev, opts("Prev Git"))
vim.keymap.set("n", "]c", api.node.navigate.git.next, opts("Next Git"))
vim.keymap.set("n", "d", api.fs.remove, opts("Delete"))
vim.keymap.set("n", "D", api.fs.trash, opts("Trash"))
vim.keymap.set("n", "E", api.tree.expand_all, opts("Expand All"))
vim.keymap.set("n", "e", api.fs.rename_basename, opts("Rename: Basename"))
vim.keymap.set("n", "]e", api.node.navigate.diagnostics.next, opts("Next Diagnostic"))
vim.keymap.set("n", "[e", api.node.navigate.diagnostics.prev, opts("Prev Diagnostic"))
vim.keymap.set("n", "<C-F>", api.live_filter.clear, opts("Clean Filter"))
vim.keymap.set("n", "F", api.live_filter.start, opts("Filter"))
vim.keymap.set("n", "g?", api.tree.toggle_help, opts("Help"))
vim.keymap.set("n", "gy", api.fs.copy.absolute_path, opts("Copy Absolute Path"))
vim.keymap.set("n", "H", api.tree.toggle_hidden_filter, opts("Toggle Dotfiles"))
vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, opts("Toggle Git Ignore"))
vim.keymap.set("n", "J", api.node.navigate.sibling.last, opts("Last Sibling"))
vim.keymap.set("n", "K", api.node.navigate.sibling.first, opts("First Sibling"))
vim.keymap.set("n", "m", api.marks.toggle, opts("Toggle Bookmark"))
vim.keymap.set("n", "o", api.node.open.edit, opts("Open"))
vim.keymap.set("n", "O", api.node.open.no_window_picker, opts("Open: No Window Picker"))
vim.keymap.set("n", "p", api.fs.paste, opts("Paste"))
vim.keymap.set("n", "P", api.node.navigate.parent, opts("Parent Directory"))
vim.keymap.set("n", "q", api.tree.close, opts("Close"))
vim.keymap.set("n", "r", api.fs.rename, opts("Rename"))
vim.keymap.set("n", "R", api.tree.reload, opts("Refresh"))
vim.keymap.set("n", "s", api.node.run.system, opts("Run System"))
vim.keymap.set("n", "S", api.tree.search_node, opts("Search"))
vim.keymap.set("n", "U", api.tree.toggle_custom_filter, opts("Toggle Hidden"))
vim.keymap.set("n", "W", api.tree.collapse_all, opts("Collapse"))
vim.keymap.set("n", "x", api.fs.cut, opts("Cut"))
vim.keymap.set("n", "y", api.fs.copy.filename, opts("Copy Name"))
vim.keymap.set("n", "Y", api.fs.copy.relative_path, opts("Copy Relative Path"))
vim.keymap.set("n", "<2-LeftMouse>", api.node.open.edit, opts("Open"))
vim.keymap.set("n", "<2-RightMouse>", api.tree.change_root_to_node, opts("CD"))
end,
-- respect_buf_cwd = true,
sync_root_with_cwd = true,
prefer_startup_root = true,
view = {
centralize_selection = false,
side = "right",
},
renderer = {
group_empty = true,
special_files = { "cargo.toml", "makefile", "readme.md", "readme.md" },
symlink_destination = true,
},
hijack_directories = {
enable = true,
auto_open = true,
},
update_focused_file = {
enable = true,
-- update_cwd = true,
update_root = false,
ignore_list = {},
},
system_open = {
cmd = "",
args = {},
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
restrict_above_cwd = false,
},
expand_all = {
max_folder_discovery = 300,
exclude = {},
},
},
},
},
}

View file

@ -1,3 +1,5 @@
local Util = require("lazyvim.util")
return {
{
"LazyVim/LazyVim",
@ -266,4 +268,48 @@ return {
ft = { "markdown", "tex", "typst", "typ" },
lazy = true,
},
{
"smjonas/inc-rename.nvim",
lazy = true,
event = "BufEnter",
config = function()
require("inc_rename").setup({
cmd_name = "IncRename", -- the name of the command
hl_group = "Substitute", -- the highlight group used for highlighting the identifier's new name
preview_empty_name = true, -- whether an empty new name should be previewed; if false the command preview will be cancelled instead
show_message = true, -- whether to display a `Renamed m instances in n files` message after a rename operation
input_buffer_type = nil, -- the type of the external input buffer to use (the only supported value is currently "dressing")
post_hook = nil, -- callback to run after renaming, receives the result table (from LSP handler) as an argument
})
end,
},
{
"nvim-neo-tree/neo-tree.nvim",
opts = {
window = {
position = "right",
mappings = {
["l"] = "none",
},
},
},
keys = {
{
"<leader>fe",
function()
require("neo-tree.command").execute({ position = "right", toggle = true, dir = Util.root() })
end,
desc = "Explorer NeoTree (root dir)",
},
{
"<leader>fE",
function()
require("neo-tree.command").execute({ position = "right", toggle = true, dir = vim.loop.cwd() })
end,
desc = "Explorer NeoTree (cwd)",
},
{ "<A-f>", "<leader>fe", desc = "Explorer NeoTree (root dir)", remap = true },
{ "<A-F>", "<leader>fE", desc = "Explorer NeoTree (cwd)", remap = true },
},
},
}