updates to integrate with code better
This commit is contained in:
parent
a637f87be0
commit
136d75b543
@ -1,2 +1,13 @@
|
|||||||
require("lazyvim") -- my config based on folkes LazyVim starter
|
if not vim.g.vscode then
|
||||||
-- require("chris") -- my config based on Christian Chiarullis work
|
require("lazyvim") -- my config based on folkes LazyVim starter
|
||||||
|
-- require("chris") -- my config based on Christian Chiarullis work
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
|
-- Add some vscode specific keymaps
|
||||||
|
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
|
||||||
|
vim.keymap.set("n", "<leader>/", [[<cmd>call VSCodeNotify('workbench.action.findInFiles')<cr>]])
|
||||||
|
vim.keymap.set("n", "<leader>ss", [[<cmd>call VSCodeNotify('workbench.action.gotoSymbol')<cr>]])
|
||||||
|
|||||||
@ -1,27 +1,27 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function load(name)
|
local function load(name)
|
||||||
local Util = require("lazy.core.util")
|
local Util = require("lazy.core.util")
|
||||||
-- always load lazyvim, then user file
|
-- always load lazyvim, then user file
|
||||||
for _, mod in ipairs({ "lazyvim.config." .. name, "config." .. name }) do
|
for _, mod in ipairs({ "lazyvim.config." .. name, "config." .. name }) do
|
||||||
Util.try(function()
|
Util.try(function()
|
||||||
require(mod)
|
require(mod)
|
||||||
end, {
|
end, {
|
||||||
msg = "Failed loading " .. mod,
|
msg = "Failed loading " .. mod,
|
||||||
on_error = function(msg)
|
on_error = function(msg)
|
||||||
local modpath = require("lazy.core.cache").find(mod)
|
local modpath = require("lazy.core.cache").find(mod)
|
||||||
if modpath then
|
if modpath then
|
||||||
Util.error(msg)
|
Util.error(msg)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
load("options")
|
load("options")
|
||||||
load("autocmds")
|
load("autocmds")
|
||||||
load("keymaps")
|
load("keymaps")
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
"--filter=blob:none",
|
"--filter=blob:none",
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
"--branch=stable",
|
"--branch=stable",
|
||||||
lazypath,
|
lazypath,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- map leader and register keymap for Lazy.
|
-- map leader and register keymap for Lazy.
|
||||||
@ -20,24 +20,10 @@ vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
|||||||
|
|
||||||
require("lazyvim.config").setup()
|
require("lazyvim.config").setup()
|
||||||
|
|
||||||
if not vim.g.vscode then
|
require("lazy").setup({
|
||||||
require("lazy").setup({
|
spec = "lazyvim.plugins",
|
||||||
spec = "lazyvim.plugins",
|
defaults = { lazy = true, version = false },
|
||||||
defaults = { lazy = true, version = false },
|
checker = { enabled = true },
|
||||||
checker = { enabled = true },
|
})
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This might not be best, but it allows for easy resetting
|
require("lazyvim.utils").setColorscheme()
|
||||||
ColorMe = function()
|
|
||||||
local colorscheme = "gruvbox-material"
|
|
||||||
|
|
||||||
local okay, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
|
||||||
|
|
||||||
if not okay then
|
|
||||||
vim.notify("Colorscheme " .. colorscheme .. " not found!")
|
|
||||||
vim.cmd("colorsheme habamax")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ColorMe()
|
|
||||||
|
|||||||
@ -1,56 +1,89 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
"hrsh7th/cmp-path",
|
"hrsh7th/cmp-path",
|
||||||
"hrsh7th/cmp-emoji",
|
"hrsh7th/cmp-emoji",
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-buffer",
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
},
|
{
|
||||||
config = function()
|
"zbirenbaum/copilot-cmp",
|
||||||
local cmp = require("cmp")
|
dependencies = "copilot.lua",
|
||||||
cmp.setup({
|
opts = {},
|
||||||
completion = {
|
config = function(_, opts)
|
||||||
completeopt = "menu,menuone,noinsert",
|
local copilot_cmp = require("copilot_cmp")
|
||||||
},
|
copilot_cmp.setup(opts)
|
||||||
snippet = {
|
-- attach cmp source whenever copilot attaches
|
||||||
expand = function(args)
|
-- fixes lazy-loading issues with the copilot cmp source
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("lazyvim.utils").on_attach(function(client)
|
||||||
end,
|
if client.name == "copilot" then
|
||||||
},
|
copilot_cmp._on_insert_enter({})
|
||||||
mapping = cmp.mapping.preset.insert({
|
end
|
||||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
end)
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
end,
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
},
|
||||||
["<C-e>"] = cmp.mapping.abort(),
|
},
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
config = function()
|
||||||
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
local cmp = require("cmp")
|
||||||
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
cmp.setup({
|
||||||
}),
|
completion = {
|
||||||
sources = cmp.config.sources({
|
completeopt = "menu,menuone,noinsert",
|
||||||
{ name = "nvim_lsp" },
|
},
|
||||||
{ name = "luasnip" },
|
snippet = {
|
||||||
{ name = "path" },
|
expand = function(args)
|
||||||
{ name = "emoji" },
|
require("luasnip").lsp_expand(args.body)
|
||||||
{ name = "buffer" },
|
end,
|
||||||
}),
|
},
|
||||||
formatting = {
|
mapping = cmp.mapping.preset.insert({
|
||||||
format = function(_, item)
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
local icons = require("lazyvim.config.icons").kind
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
if icons[item.kind] then
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
item.kind = icons[item.kind] .. " " .. item.kind
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
end
|
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
return item
|
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||||
end,
|
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||||
},
|
}),
|
||||||
experimental = {
|
sources = cmp.config.sources({
|
||||||
ghost_text = {
|
{ name = "nvim_lsp" },
|
||||||
hl_group = "LspCodeLens",
|
{ name = "luasnip" },
|
||||||
},
|
{ name = "path" },
|
||||||
},
|
{ name = "emoji" },
|
||||||
})
|
{ name = "buffer" },
|
||||||
end,
|
{ name = "copilot" },
|
||||||
},
|
}),
|
||||||
|
formatting = {
|
||||||
|
format = function(_, item)
|
||||||
|
local icons = require("lazyvim.config.icons").kind
|
||||||
|
if icons[item.kind] then
|
||||||
|
item.kind = icons[item.kind] .. " " .. item.kind
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
experimental = {
|
||||||
|
ghost_text = {
|
||||||
|
hl_group = "LspCodeLens",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"zbirenbaum/copilot-cmp",
|
||||||
|
dependencies = "copilot.lua",
|
||||||
|
opts = {},
|
||||||
|
config = function(_, opts)
|
||||||
|
local copilot_cmp = require("copilot_cmp")
|
||||||
|
copilot_cmp.setup(opts)
|
||||||
|
-- attach cmp source whenever copilot attaches
|
||||||
|
-- fixes lazy-loading issues with the copilot cmp source
|
||||||
|
require("lazyvim.utils").on_attach(function(client)
|
||||||
|
if client.name == "copilot" then
|
||||||
|
copilot_cmp._on_insert_enter({})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,212 +1,212 @@
|
|||||||
local icons = require("lazyvim.config.icons")
|
local icons = require("lazyvim.config.icons")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"RRethy/vim-illuminate",
|
"RRethy/vim-illuminate",
|
||||||
event = "BufReadPost",
|
event = "BufReadPost",
|
||||||
config = function()
|
config = function()
|
||||||
require("illuminate").configure({ delay = 200 })
|
require("illuminate").configure({ delay = 200 })
|
||||||
end,
|
end,
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
keys = {
|
keys = {
|
||||||
{ "]]", function() require("illuminate").goto_next_reference(false) end, desc = "Next Reference", },
|
{ "]]", function() require("illuminate").goto_next_reference(false) end, desc = "Next Reference", },
|
||||||
{ "[[", function() require("illuminate").goto_prev_reference(false) end, desc = "Prev Reference" },
|
{ "[[", function() require("illuminate").goto_prev_reference(false) end, desc = "Prev Reference" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nvim-lua/popup.nvim",
|
"nvim-lua/popup.nvim",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"folke/neodev.nvim",
|
"folke/neodev.nvim",
|
||||||
},
|
},
|
||||||
-- {
|
-- {
|
||||||
-- "rcarriga/nvim-notify",
|
-- "rcarriga/nvim-notify",
|
||||||
-- opts = {
|
-- opts = {
|
||||||
-- -- Animation style (see below for details)
|
-- -- Animation style (see below for details)
|
||||||
-- stages = "static",
|
-- stages = "static",
|
||||||
--
|
--
|
||||||
-- -- Render function for notifications. See notify-render()
|
-- -- Render function for notifications. See notify-render()
|
||||||
-- render = "default",
|
-- render = "default",
|
||||||
--
|
--
|
||||||
-- -- Default timeout for notifications
|
-- -- Default timeout for notifications
|
||||||
-- timeout = 2000,
|
-- timeout = 2000,
|
||||||
--
|
--
|
||||||
-- -- For stages that change opacity this is treated as the highlight behind the window
|
-- -- For stages that change opacity this is treated as the highlight behind the window
|
||||||
-- -- Set this to either a highlight group or an RGB hex value e.g. "#000000"
|
-- -- Set this to either a highlight group or an RGB hex value e.g. "#000000"
|
||||||
-- background_colour = "Normal",
|
-- background_colour = "Normal",
|
||||||
--
|
--
|
||||||
-- -- Minimum width for notification windows
|
-- -- Minimum width for notification windows
|
||||||
-- minimum_width = 10,
|
-- minimum_width = 10,
|
||||||
--
|
--
|
||||||
-- -- Icons for the different levels
|
-- -- Icons for the different levels
|
||||||
-- icons = {
|
-- icons = {
|
||||||
-- ERROR = icons.diagnostics.Error,
|
-- ERROR = icons.diagnostics.Error,
|
||||||
-- WARN = icons.diagnostics.Warning,
|
-- WARN = icons.diagnostics.Warning,
|
||||||
-- INFO = icons.diagnostics.Information,
|
-- INFO = icons.diagnostics.Information,
|
||||||
-- DEBUG = icons.ui.Bug,
|
-- DEBUG = icons.ui.Bug,
|
||||||
-- TRACE = icons.ui.Pencil,
|
-- TRACE = icons.ui.Pencil,
|
||||||
-- },
|
-- },
|
||||||
-- },
|
-- },
|
||||||
-- },
|
-- },
|
||||||
{
|
{
|
||||||
"echasnovski/mini.bufremove",
|
"echasnovski/mini.bufremove",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" },
|
{ "<leader>bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" },
|
||||||
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
|
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
-- {
|
-- {
|
||||||
-- "ghillb/cybu.nvim",
|
-- "ghillb/cybu.nvim",
|
||||||
-- event = "VeryLazy",
|
-- event = "VeryLazy",
|
||||||
-- keys = {
|
-- keys = {
|
||||||
-- { "<leader>bl", "<cmd>CybuNext<cr>", desc = "Next Buffer" },
|
-- { "<leader>bl", "<cmd>CybuNext<cr>", desc = "Next Buffer" },
|
||||||
-- { "<leader>bh", "<cmd>CybuPrev<cr>", desc = "Prev Buffer" },
|
-- { "<leader>bh", "<cmd>CybuPrev<cr>", desc = "Prev Buffer" },
|
||||||
-- },
|
-- },
|
||||||
-- opts = {
|
-- opts = {
|
||||||
-- position = {
|
-- position = {
|
||||||
-- relative_to = "win", -- win, editor, cursor
|
-- relative_to = "win", -- win, editor, cursor
|
||||||
-- anchor = "topright", -- topleft, topcenter, topright,
|
-- anchor = "topright", -- topleft, topcenter, topright,
|
||||||
-- -- centerleft, center, centerright,
|
-- -- centerleft, center, centerright,
|
||||||
-- -- bottomleft, bottomcenter, bottomright
|
-- -- bottomleft, bottomcenter, bottomright
|
||||||
-- -- vertical_offset = 10, -- vertical offset from anchor in lines
|
-- -- vertical_offset = 10, -- vertical offset from anchor in lines
|
||||||
-- -- horizontal_offset = 0, -- vertical offset from anchor in columns
|
-- -- horizontal_offset = 0, -- vertical offset from anchor in columns
|
||||||
-- -- max_win_height = 5, -- height of cybu window in lines
|
-- -- max_win_height = 5, -- height of cybu window in lines
|
||||||
-- -- max_win_width = 0.5, -- integer for absolute in columns
|
-- -- max_win_width = 0.5, -- integer for absolute in columns
|
||||||
-- -- float for relative to win/editor width
|
-- -- float for relative to win/editor width
|
||||||
-- },
|
-- },
|
||||||
-- display_time = 1750, -- time the cybu window is displayed
|
-- display_time = 1750, -- time the cybu window is displayed
|
||||||
-- style = {
|
-- style = {
|
||||||
-- separator = " ", -- string used as separator
|
-- separator = " ", -- string used as separator
|
||||||
-- prefix = "…", -- string used as prefix for truncated paths
|
-- prefix = "…", -- string used as prefix for truncated paths
|
||||||
-- padding = 1, -- left & right padding in number of spaces
|
-- padding = 1, -- left & right padding in number of spaces
|
||||||
-- hide_buffer_id = true,
|
-- hide_buffer_id = true,
|
||||||
-- devicons = {
|
-- devicons = {
|
||||||
-- enabled = true, -- enable or disable web dev icons
|
-- enabled = true, -- enable or disable web dev icons
|
||||||
-- colored = true, -- enable color for web dev icons
|
-- colored = true, -- enable color for web dev icons
|
||||||
-- },
|
-- },
|
||||||
-- },
|
-- },
|
||||||
-- },
|
-- },
|
||||||
-- },
|
-- },
|
||||||
{
|
{
|
||||||
"mbbill/undotree",
|
"mbbill/undotree",
|
||||||
cmd = { "UndotreeToggle" },
|
cmd = { "UndotreeToggle" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"MunifTanjim/nui.nvim",
|
"MunifTanjim/nui.nvim",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kyazdani42/nvim-web-devicons",
|
"kyazdani42/nvim-web-devicons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
opts = {},
|
opts = {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = {
|
opts = {
|
||||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||||
ignored_next_char = "[%w%.*]", -- don't place autopairs when cursor sits infront of any character.
|
ignored_next_char = "[%w%.*]", -- don't place autopairs when cursor sits infront of any character.
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
require("nvim-autopairs").setup(opts)
|
require("nvim-autopairs").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"preservim/vim-markdown",
|
"preservim/vim-markdown",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nacro90/numb.nvim",
|
"nacro90/numb.nvim",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("numb").setup({
|
require("numb").setup({
|
||||||
show_numbers = true, -- enable 'number' for the window while peeking
|
show_numbers = true, -- enable 'number' for the window while peeking
|
||||||
show_cursorline = true, -- enable 'cursorline' for window wdile peeking
|
show_cursorline = true, -- enable 'cursorline' for window wdile peeking
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"junegunn/vim-slash",
|
"junegunn/vim-slash",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"folke/zen-mode.nvim",
|
"folke/zen-mode.nvim",
|
||||||
cmd = { "ZenMode" },
|
cmd = { "ZenMode" },
|
||||||
config = function()
|
config = function()
|
||||||
require("zen-mode").setup({
|
require("zen-mode").setup({
|
||||||
window = {
|
window = {
|
||||||
backdrop = 1,
|
backdrop = 1,
|
||||||
height = 0.9,
|
height = 0.9,
|
||||||
width = 80,
|
width = 80,
|
||||||
options = {
|
options = {
|
||||||
signcolumn = "no",
|
signcolumn = "no",
|
||||||
number = false,
|
number = false,
|
||||||
relativenumber = false,
|
relativenumber = false,
|
||||||
cursorline = true,
|
cursorline = true,
|
||||||
cursorcolumn = false, -- disable cursor column
|
cursorcolumn = false, -- disable cursor column
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins = {
|
plugins = {
|
||||||
gitsigns = { enabled = false },
|
gitsigns = { enabled = false },
|
||||||
tmux = { enabled = false },
|
tmux = { enabled = false },
|
||||||
twilight = { enabled = false },
|
twilight = { enabled = false },
|
||||||
},
|
},
|
||||||
on_open = function()
|
on_open = function()
|
||||||
vim.g.cmp_active = false
|
vim.g.cmp_active = false
|
||||||
vim.cmd([[LspStop]])
|
vim.cmd([[LspStop]])
|
||||||
vim.opt.sidescrolloff = 0
|
vim.opt.sidescrolloff = 0
|
||||||
end,
|
end,
|
||||||
on_close = function()
|
on_close = function()
|
||||||
vim.g.cmp_active = true
|
vim.g.cmp_active = true
|
||||||
vim.cmd([[LspStart]])
|
vim.cmd([[LspStart]])
|
||||||
vim.opt.sidescrolloff = 8
|
vim.opt.sidescrolloff = 8
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"echasnovski/mini.surround",
|
"echasnovski/mini.surround",
|
||||||
keys = { "gz" },
|
keys = { "gz" },
|
||||||
opts = {
|
opts = {
|
||||||
mappings = {
|
mappings = {
|
||||||
add = "gza", -- Add surrounding in Normal and Visual modes
|
add = "gza", -- Add surrounding in Normal and Visual modes
|
||||||
delete = "gzd", -- Delete surrounding
|
delete = "gzd", -- Delete surrounding
|
||||||
find = "gzf", -- Find surrounding (to the right)
|
find = "gzf", -- Find surrounding (to the right)
|
||||||
find_left = "gzF", -- Find surrounding (to the left)
|
find_left = "gzF", -- Find surrounding (to the left)
|
||||||
highlight = "gzh", -- Highlight surrounding
|
highlight = "gzh", -- Highlight surrounding
|
||||||
replace = "gzr", -- Replace surrounding
|
replace = "gzr", -- Replace surrounding
|
||||||
update_n_lines = "gzn", -- Update `n_lines`
|
update_n_lines = "gzn", -- Update `n_lines`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
-- use gz mappings instead of s to prevent conflict with leap
|
-- use gz mappings instead of s to prevent conflict with leap
|
||||||
require("mini.surround").setup(opts)
|
require("mini.surround").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"danymat/neogen",
|
"danymat/neogen",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("neogen").setup({
|
require("neogen").setup({
|
||||||
enabled = true,
|
enabled = true,
|
||||||
input_after_comment = true,
|
input_after_comment = true,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"SmiteshP/nvim-navic",
|
"SmiteshP/nvim-navic",
|
||||||
init = function()
|
init = function()
|
||||||
vim.g.navic_silence = true
|
vim.g.navic_silence = true
|
||||||
require("lazyvim.utils").on_attach(function(client, buffer)
|
require("lazyvim.utils").on_attach(function(client, buffer)
|
||||||
if client.server_capabilities.documentSymbolProvider then
|
if client.server_capabilities.documentSymbolProvider then
|
||||||
require("nvim-navic").attach(client, buffer)
|
require("nvim-navic").attach(client, buffer)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
opts = { separator = " ", highlight = true, depth_limit = 5 },
|
opts = { separator = " ", highlight = true, depth_limit = 5 },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,247 +1,251 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = {
|
opts = {
|
||||||
plugins = {
|
plugins = {
|
||||||
-- marks = true, -- shows a list of your marks on ' and `
|
-- marks = true, -- shows a list of your marks on ' and `
|
||||||
-- registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
-- registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
||||||
spelling = {
|
spelling = {
|
||||||
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
|
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
|
||||||
suggestions = 20, -- how many suggestions should be shown in the list?
|
suggestions = 20, -- how many suggestions should be shown in the list?
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
key_labels = {
|
key_labels = {
|
||||||
-- override the label used to display some keys. It doesn't effect WK in any other way.
|
-- override the label used to display some keys. It doesn't effect WK in any other way.
|
||||||
["<leader>"] = "SPC",
|
["<leader>"] = "SPC",
|
||||||
},
|
},
|
||||||
icons = {
|
icons = {
|
||||||
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
|
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
|
||||||
separator = "➜", -- symbol used between a key and it's label
|
separator = "➜", -- symbol used between a key and it's label
|
||||||
group = "+", -- symbol prepended to a group
|
group = "+", -- symbol prepended to a group
|
||||||
},
|
},
|
||||||
popup_mappings = {
|
popup_mappings = {
|
||||||
scroll_down = "<C-d>", -- binding to scroll down inside the popup
|
scroll_down = "<C-d>", -- binding to scroll down inside the popup
|
||||||
scroll_up = "<C-u>", -- binding to scroll up inside the popup
|
scroll_up = "<C-u>", -- binding to scroll up inside the popup
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
border = "rounded", -- none, single, double, shadow
|
border = "rounded", -- none, single, double, shadow
|
||||||
position = "bottom", -- bottom, top
|
position = "bottom", -- bottom, top
|
||||||
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
|
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
|
||||||
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
|
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
|
||||||
winblend = 0,
|
winblend = 0,
|
||||||
},
|
},
|
||||||
layout = {
|
layout = {
|
||||||
height = { min = 4, max = 25 }, -- min and max height of the columns
|
height = { min = 4, max = 25 }, -- min and max height of the columns
|
||||||
width = { min = 20, max = 50 }, -- min and max width of the columns
|
width = { min = 20, max = 50 }, -- min and max width of the columns
|
||||||
spacing = 3, -- spacing between columns
|
spacing = 3, -- spacing between columns
|
||||||
align = "center", -- align columns left, center or right
|
align = "center", -- align columns left, center or right
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
local whichkey = require("which-key")
|
local whichkey = require("which-key")
|
||||||
local utils = require("lazyvim.utils")
|
local utils = require("lazyvim.utils")
|
||||||
|
|
||||||
whichkey.setup(opts)
|
whichkey.setup(opts)
|
||||||
|
|
||||||
local leader_opts = {
|
local leader_opts = {
|
||||||
mode = { "n", "v" }, -- NORMAL/VISUAL mode
|
mode = { "n", "v" }, -- NORMAL/VISUAL mode
|
||||||
buffer = nil, -- Global mappings
|
buffer = nil, -- Global mappings
|
||||||
prefix = "<leader>",
|
prefix = "<leader>",
|
||||||
silent = true, -- use 'silent'
|
silent = true, -- use 'silent'
|
||||||
noremap = true, -- use 'noremap'
|
noremap = true, -- use 'noremap'
|
||||||
nowait = true, -- use 'nowait'
|
nowait = true, -- use 'nowait'
|
||||||
}
|
}
|
||||||
|
|
||||||
whichkey.register({
|
whichkey.register({
|
||||||
mode = { "n", "v" },
|
mode = { "n", "v" },
|
||||||
["g"] = { name = "+goto" },
|
["g"] = { name = "+goto" },
|
||||||
["m"] = { name = "+harpoon" },
|
["m"] = { name = "+harpoon" },
|
||||||
["]"] = { name = "+next" },
|
["]"] = { name = "+next" },
|
||||||
["["] = { name = "+previous" },
|
["["] = { name = "+previous" },
|
||||||
})
|
})
|
||||||
|
|
||||||
local leader_mappings = {
|
local leader_mappings = {
|
||||||
b = { name = "+buffer" },
|
b = { name = "+buffer" },
|
||||||
r = { name = "+replace" },
|
r = { name = "+replace" },
|
||||||
s = { name = "+search" },
|
s = { name = "+search" },
|
||||||
h = { name = "+help" },
|
h = { name = "+help" },
|
||||||
gh = { name = "+hunks" },
|
gh = { name = "+hunks" },
|
||||||
t = { name = "+todo" },
|
t = { name = "+todo" },
|
||||||
N = { name = "+noice" },
|
N = { name = "+noice" },
|
||||||
|
|
||||||
e = { "<cmd>NvimTreeToggle<cr>", "Explorer" },
|
Z = { "<cmd>ZenMode<cr>", "Zen" },
|
||||||
Z = { "<cmd>ZenMode<cr>", "Zen" },
|
u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" },
|
||||||
u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" },
|
["'"] = { "<cmd>close<CR>", "Close split" },
|
||||||
["'"] = { "<cmd>close<CR>", "Close split" },
|
|
||||||
|
|
||||||
n = {
|
c = {
|
||||||
name = "+neorg",
|
name = "+copilot",
|
||||||
n = { "<cmd>Neorg<cr>", "Open Neorg" },
|
c = { "<cmd>Copilot<cr>", "Start Copilot" },
|
||||||
c = { "<cmd>Neorg toggle-concealer<cr>", "Toggle Concealer" },
|
},
|
||||||
t = { "<cmd>Neorg tangle current-file<cr>", "Tangle Current File" },
|
|
||||||
j = { "<cmd>Neorg journal<cr>", "Open Neorg Journal" },
|
|
||||||
w = {
|
|
||||||
function()
|
|
||||||
require("lazyvim.utils.neorg").workspace_switcher()
|
|
||||||
end,
|
|
||||||
"Workspace Switcher",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
f = {
|
n = {
|
||||||
name = "+file",
|
name = "+neorg",
|
||||||
n = { "<cmd>enew<cr>", "New File" },
|
n = { "<cmd>Neorg<cr>", "Open Neorg" },
|
||||||
},
|
c = { "<cmd>Neorg toggle-concealer<cr>", "Toggle Concealer" },
|
||||||
|
t = { "<cmd>Neorg tangle current-file<cr>", "Tangle Current File" },
|
||||||
|
j = { "<cmd>Neorg journal<cr>", "Open Neorg Journal" },
|
||||||
|
w = {
|
||||||
|
function()
|
||||||
|
require("lazyvim.utils.neorg").workspace_switcher()
|
||||||
|
end,
|
||||||
|
"Workspace Switcher",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
q = {
|
f = {
|
||||||
name = "+quit",
|
name = "+file",
|
||||||
q = { "<cmd>wq<CR>", "Save and Quit Current" },
|
n = { "<cmd>enew<cr>", "New File" },
|
||||||
a = { "<cmd>wqa<cr>", "Save and Quit all" },
|
},
|
||||||
},
|
|
||||||
|
|
||||||
l = {
|
q = {
|
||||||
name = "+lsp",
|
name = "+quit",
|
||||||
l = { "<cmd>lopen<cr>", "Open Location List" },
|
q = { "<cmd>wq<CR>", "Save and Quit Current" },
|
||||||
q = { "<cmd>copen<cr>", "Open Quickfix List" },
|
a = { "<cmd>wqa<cr>", "Save and Quit all" },
|
||||||
},
|
},
|
||||||
|
|
||||||
c = {
|
l = {
|
||||||
name = "Compiler",
|
name = "+lsp",
|
||||||
c = { "<cmd>w! | !compiler %<cr>", "Compile File" },
|
l = { "<cmd>lopen<cr>", "Open Location List" },
|
||||||
b = { "<cmd>w! | !pandoc % -t beamer -o presentation.pdf<cr>", "Beamer Presentation" },
|
q = { "<cmd>copen<cr>", "Open Quickfix List" },
|
||||||
p = { "<cmd>!opout %<cr><cr>", "Preview Document" },
|
},
|
||||||
},
|
|
||||||
|
|
||||||
w = {
|
C = {
|
||||||
name = "+window",
|
name = "+compiler",
|
||||||
w = { "<C-W>p", "Other window" },
|
c = { "<cmd>w! | !compiler %<cr>", "Compile File" },
|
||||||
d = { "<C-W>c", "Delete Window" },
|
b = { "<cmd>w! | !pandoc % -t beamer -o presentation.pdf<cr>", "Beamer Presentation" },
|
||||||
h = { "<C-W>s", "Split Below" },
|
p = { "<cmd>!opout %<cr><cr>", "Preview Document" },
|
||||||
v = { "<C-W>v", "Split Right" },
|
},
|
||||||
},
|
|
||||||
|
|
||||||
o = {
|
w = {
|
||||||
name = "+option",
|
name = "+window",
|
||||||
f = {
|
w = { "<C-W>p", "Other window" },
|
||||||
function()
|
d = { "<C-W>c", "Delete Window" },
|
||||||
require("lazyvim.plugins.lsp.format").toggle()
|
h = { "<C-W>s", "Split Below" },
|
||||||
end,
|
v = { "<C-W>v", "Split Right" },
|
||||||
"Toggle format on save",
|
},
|
||||||
},
|
|
||||||
s = {
|
|
||||||
function()
|
|
||||||
utils.toggle("spell")
|
|
||||||
end,
|
|
||||||
"Toggle spelling",
|
|
||||||
},
|
|
||||||
w = {
|
|
||||||
function()
|
|
||||||
utils.toggle("wrap")
|
|
||||||
end,
|
|
||||||
"Toggle word wrap",
|
|
||||||
},
|
|
||||||
n = {
|
|
||||||
function()
|
|
||||||
utils.toggle("relativenumber", true)
|
|
||||||
utils.toggle("number")
|
|
||||||
end,
|
|
||||||
"Toggle line numbers",
|
|
||||||
},
|
|
||||||
d = {
|
|
||||||
function()
|
|
||||||
utils.toggle_diagnostics()
|
|
||||||
end,
|
|
||||||
"Toggle Diagnostics",
|
|
||||||
},
|
|
||||||
c = {
|
|
||||||
function()
|
|
||||||
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
|
|
||||||
utils.toggle("conceallevel", false, { 0, conceallevel })
|
|
||||||
end,
|
|
||||||
"Toggle conceal",
|
|
||||||
},
|
|
||||||
h = {
|
|
||||||
function()
|
|
||||||
local sidescrolloff = vim.o.sidescrolloff > 0 and vim.o.sidescrolloff or 8
|
|
||||||
utils.toggle("sidescrolloff", false, { 0, sidescrolloff })
|
|
||||||
end,
|
|
||||||
"Toggle side scroll off",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
g = {
|
o = {
|
||||||
name = "+git",
|
name = "+option",
|
||||||
g = {
|
f = {
|
||||||
function()
|
function()
|
||||||
utils.float_term({ "lazygit" })
|
require("lazyvim.plugins.lsp.format").toggle()
|
||||||
end,
|
end,
|
||||||
"Lazygit (cwd)",
|
"Toggle format on save",
|
||||||
},
|
},
|
||||||
G = {
|
s = {
|
||||||
function()
|
function()
|
||||||
utils.float_term({ "lazygit" }, { cwd = utils.get_root() })
|
utils.toggle("spell")
|
||||||
end,
|
end,
|
||||||
"Lazygit (root dir)",
|
"Toggle spelling",
|
||||||
},
|
},
|
||||||
},
|
w = {
|
||||||
|
function()
|
||||||
|
utils.toggle("wrap")
|
||||||
|
end,
|
||||||
|
"Toggle word wrap",
|
||||||
|
},
|
||||||
|
n = {
|
||||||
|
function()
|
||||||
|
utils.toggle("relativenumber", true)
|
||||||
|
utils.toggle("number")
|
||||||
|
end,
|
||||||
|
"Toggle line numbers",
|
||||||
|
},
|
||||||
|
d = {
|
||||||
|
function()
|
||||||
|
utils.toggle_diagnostics()
|
||||||
|
end,
|
||||||
|
"Toggle Diagnostics",
|
||||||
|
},
|
||||||
|
c = {
|
||||||
|
function()
|
||||||
|
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
|
||||||
|
utils.toggle("conceallevel", false, { 0, conceallevel })
|
||||||
|
end,
|
||||||
|
"Toggle conceal",
|
||||||
|
},
|
||||||
|
h = {
|
||||||
|
function()
|
||||||
|
local sidescrolloff = vim.o.sidescrolloff > 0 and vim.o.sidescrolloff or 8
|
||||||
|
utils.toggle("sidescrolloff", false, { 0, sidescrolloff })
|
||||||
|
end,
|
||||||
|
"Toggle side scroll off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
z = {
|
g = {
|
||||||
name = "+zk",
|
name = "+git",
|
||||||
I = { "<cmd>ZkIndex<cr>", "Index Notebook" },
|
g = {
|
||||||
n = {
|
function()
|
||||||
"+new",
|
utils.float_term({ "lazygit" })
|
||||||
n = { "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", "New Note (zk dir)" },
|
end,
|
||||||
N = {
|
"Lazygit (cwd)",
|
||||||
"<cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<cr>",
|
},
|
||||||
"New Note (cwd)",
|
G = {
|
||||||
},
|
function()
|
||||||
t = {
|
utils.float_term({ "lazygit" }, { cwd = utils.get_root() })
|
||||||
"<cmd>ZkNewFromTitleSelection { title = vim.fn.input('Title: ') }<cr>",
|
end,
|
||||||
"New, Title from selection (zk dir)",
|
"Lazygit (root dir)",
|
||||||
},
|
},
|
||||||
T = {
|
},
|
||||||
"<cmd>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') title = vim.fn.input('Title: ') }<cr>",
|
|
||||||
"New, Title from selection (cwd)",
|
|
||||||
},
|
|
||||||
c = {
|
|
||||||
"<cmd>ZkNewFromContentSelection { title = vim.fn.input('Title: ') }<cr>",
|
|
||||||
"New, Content from selection (zk dir)",
|
|
||||||
},
|
|
||||||
C = {
|
|
||||||
"<cmd>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h') title = vim.fn.input('Title: ') }<cr>",
|
|
||||||
"New, Content from selection (cwd)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
c = { "<cmd>ZkCd<cr>", "cd 'root'" },
|
|
||||||
s = { "<cmd>ZkNotes<cr>", "List Notes" },
|
|
||||||
b = { "<cmd>ZkBacklinks<cr>", "Backlinks" },
|
|
||||||
l = { "<cmd>ZkLinks<cr>", "Links" },
|
|
||||||
j = {
|
|
||||||
"<cmd>ZkNew { dir = 'journal', date = 'today', title = vim.fn.input('Title: ') }<cr>",
|
|
||||||
"New Journal",
|
|
||||||
},
|
|
||||||
i = {
|
|
||||||
{ "<cmd>ZkInsertLink<cr>", "Insert Link" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- TODO: Add dap back into the project, bashbunni's dotfiles are a good resource.
|
z = {
|
||||||
-- d = {
|
name = "+zk",
|
||||||
-- name = "Debug",
|
I = { "<cmd>ZkIndex<cr>", "Index Notebook" },
|
||||||
-- b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Breakpoint" },
|
n = {
|
||||||
-- c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
|
"+new",
|
||||||
-- i = { "<cmd>lua require'dap'.step_into()<cr>", "Into" },
|
n = { "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", "New Note (zk dir)" },
|
||||||
-- o = { "<cmd>lua require'dap'.step_over()<cr>", "Over" },
|
N = {
|
||||||
-- O = { "<cmd>lua require'dap'.step_out()<cr>", "Out" },
|
"<cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<cr>",
|
||||||
-- r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Repl" },
|
"New Note (cwd)",
|
||||||
-- l = { "<cmd>lua require'dap'.run_last()<cr>", "Last" },
|
},
|
||||||
-- u = { "<cmd>lua require'dapui'.toggle()<cr>", "UI" },
|
t = {
|
||||||
-- x = { "<cmd>lua require'dap'.terminate()<cr>", "Exit" },
|
"<cmd>ZkNewFromTitleSelection { title = vim.fn.input('Title: ') }<cr>",
|
||||||
-- },
|
"New, Title from selection (zk dir)",
|
||||||
}
|
},
|
||||||
|
T = {
|
||||||
|
"<cmd>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') title = vim.fn.input('Title: ') }<cr>",
|
||||||
|
"New, Title from selection (cwd)",
|
||||||
|
},
|
||||||
|
c = {
|
||||||
|
"<cmd>ZkNewFromContentSelection { title = vim.fn.input('Title: ') }<cr>",
|
||||||
|
"New, Content from selection (zk dir)",
|
||||||
|
},
|
||||||
|
C = {
|
||||||
|
"<cmd>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h') title = vim.fn.input('Title: ') }<cr>",
|
||||||
|
"New, Content from selection (cwd)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
c = { "<cmd>ZkCd<cr>", "cd 'root'" },
|
||||||
|
s = { "<cmd>ZkNotes<cr>", "List Notes" },
|
||||||
|
b = { "<cmd>ZkBacklinks<cr>", "Backlinks" },
|
||||||
|
l = { "<cmd>ZkLinks<cr>", "Links" },
|
||||||
|
j = {
|
||||||
|
"<cmd>ZkNew { dir = 'journal', date = 'today', title = vim.fn.input('Title: ') }<cr>",
|
||||||
|
"New Journal",
|
||||||
|
},
|
||||||
|
i = {
|
||||||
|
{ "<cmd>ZkInsertLink<cr>", "Insert Link" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
whichkey.register(leader_mappings, leader_opts)
|
-- TODO: Add dap back into the project, bashbunni's dotfiles are a good resource.
|
||||||
end,
|
-- d = {
|
||||||
},
|
-- name = "Debug",
|
||||||
|
-- b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Breakpoint" },
|
||||||
|
-- c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
|
||||||
|
-- i = { "<cmd>lua require'dap'.step_into()<cr>", "Into" },
|
||||||
|
-- o = { "<cmd>lua require'dap'.step_over()<cr>", "Over" },
|
||||||
|
-- O = { "<cmd>lua require'dap'.step_out()<cr>", "Out" },
|
||||||
|
-- r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Repl" },
|
||||||
|
-- l = { "<cmd>lua require'dap'.run_last()<cr>", "Last" },
|
||||||
|
-- u = { "<cmd>lua require'dapui'.toggle()<cr>", "UI" },
|
||||||
|
-- x = { "<cmd>lua require'dap'.terminate()<cr>", "Exit" },
|
||||||
|
-- },
|
||||||
|
}
|
||||||
|
|
||||||
|
whichkey.register(leader_mappings, leader_opts)
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,13 @@ M.root_patterns = { ".git", "/lua" }
|
|||||||
|
|
||||||
---@param on_attach fun(client, buffer)
|
---@param on_attach fun(client, buffer)
|
||||||
function M.on_attach(on_attach)
|
function M.on_attach(on_attach)
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local buffer = args.buf
|
local buffer = args.buf
|
||||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
on_attach(client, buffer)
|
on_attach(client, buffer)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns the root directory based on:
|
-- returns the root directory based on:
|
||||||
@ -20,113 +20,125 @@ end
|
|||||||
-- * root pattern of cwd
|
-- * root pattern of cwd
|
||||||
---@return string
|
---@return string
|
||||||
function M.get_root()
|
function M.get_root()
|
||||||
---@type string?
|
---@type string?
|
||||||
local path = vim.api.nvim_buf_get_name(0)
|
local path = vim.api.nvim_buf_get_name(0)
|
||||||
path = path ~= "" and vim.loop.fs_realpath(path) or nil
|
path = path ~= "" and vim.loop.fs_realpath(path) or nil
|
||||||
---@type string[]
|
---@type string[]
|
||||||
local roots = {}
|
local roots = {}
|
||||||
if path then
|
if path then
|
||||||
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||||
local workspace = client.config.workspace_folders
|
local workspace = client.config.workspace_folders
|
||||||
local paths = workspace
|
local paths = workspace
|
||||||
and vim.tbl_map(function(ws)
|
and vim.tbl_map(function(ws)
|
||||||
return vim.uri_to_fname(ws.uri)
|
return vim.uri_to_fname(ws.uri)
|
||||||
end, workspace)
|
end, workspace)
|
||||||
or client.config.root_dir and { client.config.root_dir }
|
or client.config.root_dir and { client.config.root_dir }
|
||||||
or {}
|
or {}
|
||||||
for _, p in ipairs(paths) do
|
for _, p in ipairs(paths) do
|
||||||
local r = vim.loop.fs_realpath(p)
|
local r = vim.loop.fs_realpath(p)
|
||||||
if path:find(r, 1, true) then
|
if path:find(r, 1, true) then
|
||||||
roots[#roots + 1] = r
|
roots[#roots + 1] = r
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(roots, function(a, b)
|
table.sort(roots, function(a, b)
|
||||||
return #a > #b
|
return #a > #b
|
||||||
end)
|
end)
|
||||||
---@type string?
|
---@type string?
|
||||||
local root = roots[1]
|
local root = roots[1]
|
||||||
if not root then
|
if not root then
|
||||||
path = path and vim.fs.dirname(path) or vim.loop.cwd()
|
path = path and vim.fs.dirname(path) or vim.loop.cwd()
|
||||||
---@type string?
|
---@type string?
|
||||||
root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
|
root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
|
||||||
root = root and vim.fs.dirname(root) or vim.loop.cwd()
|
root = root and vim.fs.dirname(root) or vim.loop.cwd()
|
||||||
end
|
end
|
||||||
---@cast root string
|
---@cast root string
|
||||||
return root
|
return root
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param silent boolean?
|
---@param silent boolean?
|
||||||
---@param values? {[1]:any, [2]:any}function
|
---@param values? {[1]:any, [2]:any}function
|
||||||
function M.toggle(option, silent, values)
|
function M.toggle(option, silent, values)
|
||||||
if values then
|
if values then
|
||||||
if vim.opt_local[option]:get() == values[1] then
|
if vim.opt_local[option]:get() == values[1] then
|
||||||
vim.opt_local[option] = values[2]
|
vim.opt_local[option] = values[2]
|
||||||
else
|
else
|
||||||
vim.opt_local[option] = values[1]
|
vim.opt_local[option] = values[1]
|
||||||
end
|
end
|
||||||
return vim.notify(
|
return vim.notify(
|
||||||
"Set " .. option .. " to " .. vim.opt_local[option]:get(),
|
"Set " .. option .. " to " .. vim.opt_local[option]:get(),
|
||||||
vim.log.levels.INFO,
|
vim.log.levels.INFO,
|
||||||
{ title = "Option" }
|
{ title = "Option" }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
vim.opt_local[option] = not vim.opt_local[option]:get()
|
vim.opt_local[option] = not vim.opt_local[option]:get()
|
||||||
if not silent then
|
if not silent then
|
||||||
vim.notify(
|
vim.notify(
|
||||||
(vim.opt_local[option]:get() and "Enabled" or "Disabled") .. " " .. option,
|
(vim.opt_local[option]:get() and "Enabled" or "Disabled") .. " " .. option,
|
||||||
vim.log.levels.INFO,
|
vim.log.levels.INFO,
|
||||||
{ title = "Option" }
|
{ title = "Option" }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local enabled = true
|
local enabled = true
|
||||||
function M.toggle_diagnostics()
|
function M.toggle_diagnostics()
|
||||||
enabled = not enabled
|
enabled = not enabled
|
||||||
if enabled then
|
if enabled then
|
||||||
vim.diagnostic.enable()
|
vim.diagnostic.enable()
|
||||||
vim.notify("Enabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
|
vim.notify("Enabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
|
||||||
else
|
else
|
||||||
vim.diagnostic.disable()
|
vim.diagnostic.disable()
|
||||||
vim.notify("Disabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
|
vim.notify("Disabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.smart_quit()
|
function M.smart_quit()
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local modified = vim.api.nvim_buf_get_option(bufnr, "modified")
|
local modified = vim.api.nvim_buf_get_option(bufnr, "modified")
|
||||||
if modified then
|
if modified then
|
||||||
vim.ui.input({
|
vim.ui.input({
|
||||||
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
|
prompt = "You have unsaved changes. Quit anyway? (y/n) ",
|
||||||
}, function(input)
|
}, function(input)
|
||||||
if input == "y" then
|
if input == "y" then
|
||||||
vim.cmd("q!")
|
vim.cmd("q!")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
vim.cmd("q!")
|
vim.cmd("q!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.isempty(s)
|
function M.isempty(s)
|
||||||
return s == nil or s == ""
|
return s == nil or s == ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_buf_option(opt)
|
function M.get_buf_option(opt)
|
||||||
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
|
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
return buf_option
|
return buf_option
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.telescope(builtin, opts)
|
function M.telescope(builtin, opts)
|
||||||
return function()
|
return function()
|
||||||
require("telescope.builtin")[builtin](vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}))
|
require("telescope.builtin")[builtin](vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This might not be best, but it allows for easy resetting
|
||||||
|
function M.setColorscheme(scheme)
|
||||||
|
local colorscheme = scheme or "gruvbox-material"
|
||||||
|
|
||||||
|
local okay, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||||
|
|
||||||
|
if not okay then
|
||||||
|
vim.notify("Colorscheme " .. colorscheme .. " not found!")
|
||||||
|
vim.cmd("colorsheme habamax")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user