feat(nvim): use loaded, plugin format

This commit is contained in:
Price Hiller 2022-08-02 01:27:57 -05:00
parent a3c3656a91
commit b136610a22
25 changed files with 415 additions and 327 deletions

View File

@ -1,49 +1,53 @@
local cmp = require('cmp') local loaded, cmp = pcall(require, "cmp")
local types = require('cmp.types') if not loaded then
local str = require('cmp.utils.str') return
end
local types = require("cmp.types")
local str = require("cmp.utils.str")
local compare = cmp.config.compare local compare = cmp.config.compare
local luasnip = require('luasnip') local luasnip = require("luasnip")
local kind_icons = { local kind_icons = {
Text = '', Text = "",
Method = '', Method = "",
Function = '', Function = "",
Constructor = '', Constructor = "",
Field = '', Field = "",
Variable = '', Variable = "",
Class = '', Class = "",
Interface = '', Interface = "",
Module = '', Module = "",
Property = '', Property = "",
Unit = '', Unit = "",
Value = '', Value = "",
Enum = '', Enum = "",
Keyword = '', Keyword = "",
Snippet = '', Snippet = "",
Color = '', Color = "",
File = '', File = "",
Reference = '', Reference = "",
Folder = '', Folder = "",
EnumMember = '', EnumMember = "",
Constant = '', Constant = "",
Struct = '', Struct = "",
Event = '', Event = "",
Operator = '', Operator = "",
TypeParameter = '', TypeParameter = "",
} }
-- Load Snippets -- Load Snippets
require('luasnip.loaders.from_vscode').lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
local border = { local border = {
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
{ '', 'CmpBorder' }, { "", "CmpBorder" },
} }
cmp.setup({ cmp.setup({
@ -65,32 +69,33 @@ cmp.setup({
local max = 50 local max = 50
if string.len(word) >= max then if string.len(word) >= max then
local before = string.sub(word, 1, math.floor((max - 3) / 2)) local before = string.sub(word, 1, math.floor((max - 3) / 2))
word = before .. '...' word = before .. "..."
end end
if entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet if
and string.sub(vim_item.abbr, -1, -1) == '~' entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet
and string.sub(vim_item.abbr, -1, -1) == "~"
then then
word = word .. '~' word = word .. "~"
end end
vim_item.abbr = word vim_item.abbr = word
-- Kind icons -- Kind icons
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
-- Source -- Source
vim_item.menu = ({ vim_item.menu = ({
fuzzy_buffer = '[Buffer]', fuzzy_buffer = "[Buffer]",
nvim_lsp = '[Lsp]', nvim_lsp = "[Lsp]",
luasnip = '[LuaSnip]', luasnip = "[LuaSnip]",
path = '[Path]', path = "[Path]",
calc = '[Calculator]', calc = "[Calculator]",
neorg = '[Neorg]', neorg = "[Neorg]",
emoji = '[Emoji]', emoji = "[Emoji]",
zsh = '[Zsh]', zsh = "[Zsh]",
crates = '[Crates]', crates = "[Crates]",
cmdline_history = '[Cmd History]', cmdline_history = "[Cmd History]",
rg = '[Ripgrep]', rg = "[Ripgrep]",
npm = '[Npm],', npm = "[Npm],",
conventionalcommits = '[Commit]', conventionalcommits = "[Commit]",
})[entry.source.name] })[entry.source.name]
return vim_item return vim_item
end, end,
@ -110,41 +115,41 @@ cmp.setup({
snippet = { snippet = {
-- REQUIRED - you must specify a snippet engine -- REQUIRED - you must specify a snippet engine
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users. require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
end, end,
}, },
mapping = { mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({ ["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}), }),
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ["<CR>"] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<C-Tab>'] = cmp.mapping(function(fallback) ["<C-Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
else else
fallback() fallback()
end end
end, { 'i', 's' }), end, { "i", "s" }),
['<C-S-Tab>'] = cmp.mapping(function(fallback) ["<C-S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then if luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { 'i', 's' }), end, { "i", "s" }),
['<Tab>'] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
else else
fallback() fallback()
end end
end, { 'i', 's' }), end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
@ -152,21 +157,21 @@ cmp.setup({
else else
fallback() fallback()
end end
end, { 'i', 's' }), end, { "i", "s" }),
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp', priority = 10 }, { name = "nvim_lsp", priority = 10 },
{ name = 'luasnip', priority = 9 }, -- For luasnip users. { name = "luasnip", priority = 9 }, -- For luasnip users.
{ name = 'fuzzy_buffer', priority = 8 }, { name = "fuzzy_buffer", priority = 8 },
{ name = 'rg', priority = 7 }, { name = "rg", priority = 7 },
{ name = 'path', priority = 6 }, { name = "path", priority = 6 },
{ name = 'zsh', priority = 5 }, { name = "zsh", priority = 5 },
{ name = 'emoji', keyword_length = 2 }, { name = "emoji", keyword_length = 2 },
{ name = 'neorg' }, { name = "neorg" },
{ name = 'calc' }, { name = "calc" },
{ name = 'npm', keyword_length = 2 }, { name = "npm", keyword_length = 2 },
{ {
name = 'dictionary', name = "dictionary",
keyword_length = 2, keyword_length = 2,
}, },
}), }),
@ -176,7 +181,7 @@ cmp.setup({
compare.offset, compare.offset,
compare.recently_used, compare.recently_used,
compare.exact, compare.exact,
require('cmp_fuzzy_buffer.compare'), require("cmp_fuzzy_buffer.compare"),
compare.kind, compare.kind,
compare.sort_text, compare.sort_text,
compare.length, compare.length,
@ -186,55 +191,55 @@ cmp.setup({
}) })
-- Git Commit Completions -- Git Commit Completions
cmp.setup.filetype('gitcommit', { cmp.setup.filetype("gitcommit", {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'conventionalcommits', priority = 20 }, { name = "conventionalcommits", priority = 20 },
}), }),
}) })
cmp.setup.filetype('NeogitCommitMesssage', { cmp.setup.filetype("NeogitCommitMesssage", {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'conventionalcommits', priority = 20 }, { name = "conventionalcommits", priority = 20 },
}), }),
}) })
cmp.setup.filetype('toml', { cmp.setup.filetype("toml", {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'crates' }, { name = "crates" },
}), }),
}) })
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', { cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'fuzzy_buffer' }, { name = "fuzzy_buffer" },
{ name = 'cmdline_history' }, { name = "cmdline_history" },
}), }),
}) })
cmp.setup.cmdline('?', { cmp.setup.cmdline("?", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'fuzzy_buffer' }, { name = "fuzzy_buffer" },
{ name = 'cmdline_history' }, { name = "cmdline_history" },
}), }),
}) })
cmp.setup.cmdline('@', { cmp.setup.cmdline("@", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'fuzzy_buffer' }, { name = "fuzzy_buffer" },
{ name = 'cmdline_history' }, { name = "cmdline_history" },
}), }),
}) })
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', { cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' }, { name = "path" },
{ name = 'cmdline' }, { name = "cmdline" },
{ name = 'cmdline_history' }, { name = "cmdline_history" },
}), }),
}) })

View File

@ -1,41 +1,44 @@
local dap = require('dap') local loaded, dap = pcall(require, "dap")
local async = require('plenary.async') if not loaded then
return
end
local async = require("plenary.async")
--- Gets a path for a given program in the environment --- Gets a path for a given program in the environment
---@param program @The string of a program in the PATH ---@param program @The string of a program in the PATH
---@return @The full path to the program if found, or nil if not ---@return @The full path to the program if found, or nil if not
local function get_program_path(program) local function get_program_path(program)
local home = os.getenv('HOME') local home = os.getenv("HOME")
local program_path = home .. '/.local/share/nvim/mason/packages/' .. program .. '/' .. program local program_path = home .. "/.local/share/nvim/mason/packages/" .. program .. "/" .. program
return program_path return program_path
end end
local lldb_path = get_program_path('lldb-vscode') local lldb_path = get_program_path("lldb-vscode")
-- Adapaters -- Adapaters
dap.adapters.lldb = { dap.adapters.lldb = {
type = 'executable', type = "executable",
command = lldb_path, command = lldb_path,
name = 'lldb', name = "lldb",
} }
dap.adapters.coreclr = { dap.adapters.coreclr = {
type = 'executable', type = "executable",
command = get_program_path('netcoredbg'), command = get_program_path("netcoredbg"),
args = { '--interpreter=vscode' }, args = { "--interpreter=vscode" },
} }
-- configurations -- configurations
dap.configurations.cpp = { dap.configurations.cpp = {
{ {
name = 'Launch', name = "Launch",
type = 'lldb', type = "lldb",
request = 'launch', request = "launch",
program = function() program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end, end,
cwd = '${workspaceFolder}', cwd = "${workspaceFolder}",
stopOnEntry = false, stopOnEntry = false,
targetArchitecture = 'arm64', targetArchitecture = "arm64",
args = {}, args = {},
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
@ -57,11 +60,11 @@ dap.configurations.rust = dap.configurations.cpp
dap.configurations.cs = { dap.configurations.cs = {
{ {
type = 'coreclr', type = "coreclr",
name = 'launch - netcoredbg', name = "launch - netcoredbg",
request = 'launch', request = "launch",
program = function() program = function()
return vim.fn.input('Path to dll: ', vim.fn.getcwd() .. '/bin/Debug/', 'file') return vim.fn.input("Path to dll: ", vim.fn.getcwd() .. "/bin/Debug/", "file")
end, end,
}, },
} }

View File

@ -1,3 +1,7 @@
require('neoclip').setup({ local neoclip = pcall(require, "neoclip")
if not neoclip then
return
end
neoclip.setup({
enable_persistent_history = true, enable_persistent_history = true,
}) })

View File

@ -1,49 +1,52 @@
local neorg = require('neorg') local loaded, neorg = pcall(require, "neorg")
if not loaded then
return
end
neorg.setup({ neorg.setup({
load = { load = {
['core.defaults'] = {}, ["core.defaults"] = {},
['core.norg.concealer'] = {}, ["core.norg.concealer"] = {},
['core.norg.esupports.metagen'] = { ["core.norg.esupports.metagen"] = {
config = { config = {
type = 'auto', type = "auto",
}, },
}, },
['core.integrations.nvim-cmp'] = { ["core.integrations.nvim-cmp"] = {
config = {}, config = {},
}, },
['core.norg.completion'] = { ["core.norg.completion"] = {
config = { config = {
engine = 'nvim-cmp', engine = "nvim-cmp",
}, },
}, },
['core.keybinds'] = { ["core.keybinds"] = {
config = { config = {
default_keybinds = true, default_keybinds = true,
-- norg_leader = "-" -- norg_leader = "-"
}, },
}, },
['core.norg.dirman'] = { ["core.norg.dirman"] = {
config = { config = {
workspaces = { workspaces = {
default = '~/.notes', -- Format: <name_of_workspace> = <path_to_workspace_root> default = "~/.notes", -- Format: <name_of_workspace> = <path_to_workspace_root>
}, },
autochdir = true, -- Automatically change the directory to the current workspace's root every time autochdir = true, -- Automatically change the directory to the current workspace's root every time
index = 'index.norg', -- The name of the main (root) .norg file index = "index.norg", -- The name of the main (root) .norg file
last_workspace = vim.fn.stdpath('cache') .. '/neorg_last_workspace.txt', -- The location to write and read the workspace cache file last_workspace = vim.fn.stdpath("cache") .. "/neorg_last_workspace.txt", -- The location to write and read the workspace cache file
}, },
}, },
['core.integrations.telescope'] = {}, ["core.integrations.telescope"] = {},
['core.norg.qol.toc'] = {}, ["core.norg.qol.toc"] = {},
['core.gtd.base'] = { ["core.gtd.base"] = {
config = { config = {
workspace = 'default', workspace = "default",
}, },
}, },
['core.gtd.ui'] = { ["core.gtd.ui"] = {
config = {}, config = {},
}, },
['core.gtd.helpers'] = { ["core.gtd.helpers"] = {
config = {}, config = {},
}, },
}, },

View File

@ -1,18 +1,22 @@
require('stabilize').setup({ local loaded, stabilize = pcall(require, "stabilize")
if not loaded then
return
end
stabilize.setup({
-- stabilize window even when current cursor position will be hidden behind new window -- stabilize window even when current cursor position will be hidden behind new window
force = true, force = true,
-- set context mark to register on force event which can be jumped to with '<forcemark> -- set context mark to register on force event which can be jumped to with '<forcemark>
forcemark = nil, forcemark = nil,
-- do not manage windows matching these file/buftypes -- do not manage windows matching these file/buftypes
ignore = { ignore = {
filetype = { 'packer', 'Dashboard', 'Trouble', 'TelescopePrompt' }, filetype = { "packer", "Dashboard", "Trouble", "TelescopePrompt" },
buftype = { buftype = {
'packer', "packer",
'Dashboard', "Dashboard",
'terminal', "terminal",
'quickfix', "quickfix",
'loclist', "loclist",
'LspInstall', "LspInstall",
}, },
}, },
-- comma-separated list of autocmds that wil trigger the plugins window restore function -- comma-separated list of autocmds that wil trigger the plugins window restore function

View File

@ -1,7 +0,0 @@
-- Load Animations
require('wlanimation')
-- Load a line (these include setup)
require('wlsample.bubble2')
-- In the future I may want to implement
-- my own, for now much too lazy for that

View File

@ -1,79 +1,82 @@
local alpha = require('alpha') local loaded, alpha = pcall(require, "alpha")
local startify = require('alpha.themes.startify') if not loaded then
local dashboard = require('alpha.themes.dashboard') return
end
local startify = require("alpha.themes.startify")
local dashboard = require("alpha.themes.dashboard")
-- Set header -- Set header
local header = { local header = {
type = 'text', type = "text",
val = { val = {
' ', " ",
' ', " ",
' ', " ",
' ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ', " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ",
' ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ', " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ",
' ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ', " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ",
' ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ', " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ",
' ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ', " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ",
' ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ', " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ",
' ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ', " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ",
' ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ', " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ",
' ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ', " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ",
' ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ', " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ",
' ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ', " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ",
' ', " ",
}, },
opts = { opts = {
position = 'center', position = "center",
hl = 'Function', hl = "Function",
}, },
} }
-- Subheader, plugin count -- Subheader, plugin count
local get_plugins = function() local get_plugins = function()
local num_plugins_loaded = #vim.fn.globpath(vim.fn.stdpath('data') .. '/site/pack/packer/start', '*', 0, 1) local num_plugins_loaded = #vim.fn.globpath(vim.fn.stdpath("data") .. "/site/pack/packer/start", "*", 0, 1)
local num_plugins_total = #vim.tbl_keys(packer_plugins) local num_plugins_total = #vim.tbl_keys(packer_plugins)
if num_plugins_total <= 1 then if num_plugins_total <= 1 then
return num_plugins_loaded .. ' / ' .. num_plugins_total .. ' plugin  loaded' return num_plugins_loaded .. " / " .. num_plugins_total .. " plugin  loaded"
else else
return num_plugins_loaded .. ' / ' .. num_plugins_total .. ' plugins  loaded' return num_plugins_loaded .. " / " .. num_plugins_total .. " plugins  loaded"
end end
end end
local plugin_count = { local plugin_count = {
type = 'text', type = "text",
val = { val = {
get_plugins(), get_plugins(),
}, },
opts = { opts = {
hl = 'Comment', hl = "Comment",
position = 'center', position = "center",
}, },
} }
-- Menu -- Menu
local button = function(sc, txt, keybind) local button = function(sc, txt, keybind)
local sc_ = sc:gsub('%s', ''):gsub('SPC', '<leader>') local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>")
local opts = { local opts = {
position = 'center', position = "center",
text = txt, text = txt,
shortcut = sc, shortcut = sc,
cursor = 4, cursor = 4,
width = 30, width = 30,
align_shortcut = 'right', align_shortcut = "right",
hl_shortcut = 'Number', hl_shortcut = "Number",
hl = 'Function', hl = "Function",
} }
if keybind then if keybind then
opts.keymap = { 'n', sc_, keybind, { noremap = true, silent = true } } opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } }
end end
return { return {
type = 'button', type = "button",
val = txt, val = txt,
on_press = function() on_press = function()
local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) local key = vim.api.nvim_replace_termcodes(sc_, true, false, true)
vim.api.nvim_feedkeys(key, 'normal', false) vim.api.nvim_feedkeys(key, "normal", false)
end, end,
opts = opts, opts = opts,
} }
@ -81,14 +84,14 @@ end
-- Set menu -- Set menu
local buttons = { local buttons = {
type = 'group', type = "group",
val = { val = {
button('e', ' New File', ':ene <BAR> startinsert <CR>'), button("e", " New File", ":ene <BAR> startinsert <CR>"),
button('f', ' Find File', ':Telescope find_files<CR>'), button("f", " Find File", ":Telescope find_files<CR>"),
button('r', ' Recent', ':Telescope oldfiles<CR>'), button("r", " Recent", ":Telescope oldfiles<CR>"),
button('s', ' Settings', ':e ~/.config/nvim/<CR>'), button("s", " Settings", ":e ~/.config/nvim/<CR>"),
button('u', ' Update Plugins', ':PackerSync<CR>'), button("u", " Update Plugins", ":PackerSync<CR>"),
button('q', ' Quit', ':qa<CR>'), button("q", " Quit", ":qa<CR>"),
}, },
opts = { opts = {
spacing = 0, spacing = 0,
@ -97,16 +100,16 @@ local buttons = {
-- Footer 2, fortune -- Footer 2, fortune
local fortune = { local fortune = {
type = 'text', type = "text",
val = require('alpha.fortune')(), val = require("alpha.fortune")(),
opts = { opts = {
position = 'center', position = "center",
hl = 'Comment', hl = "Comment",
}, },
} }
local padding = function() local padding = function()
return { type = 'padding', val = 4 } return { type = "padding", val = 4 }
end end
local opts = { local opts = {
layout = { layout = {
@ -126,8 +129,8 @@ local opts = {
-- Send config to alpha -- Send config to alpha
alpha.setup(opts) alpha.setup(opts)
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd("FileType", {
pattern = 'alpha', pattern = "alpha",
callback = function() callback = function()
vim.opt_local.cursorline = false vim.opt_local.cursorline = false
end, end,

View File

@ -1,17 +1,20 @@
local bufferline = require('bufferline') local loaded, bufferline = pcall(require, "bufferline")
if not loaded then
return
end
bufferline.setup({ bufferline.setup({
options = { options = {
numbers = function(opts) numbers = function(opts)
return string.format('%s', opts.id) return string.format("%s", opts.id)
end, end,
diagnostics = 'nvim_lsp', diagnostics = "nvim_lsp",
offsets = { offsets = {
{ {
filetype = 'NvimTree', filetype = "NvimTree",
text = 'File Explorer', text = "File Explorer",
highlight = 'Directory', highlight = "Directory",
text_align = 'left', text_align = "left",
}, },
}, },
}, },

View File

@ -1,10 +0,0 @@
-- Alias for vim.g
local g = vim.g
-- Run COQ on open
g.coq_settings = {
auto_start = 'shut-up',
limits = {
completion_manual_timeout = 2000,
},
}

View File

@ -1,9 +1,13 @@
local fn = vim.fn local fn = vim.fn
require('dapui').setup({}) local loaded, dapui = pcall(require, "dapui")
if not loaded then
return
end
dapui.setup({})
fn.sign_define('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', linehl = '', numhl = '' }) fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
fn.sign_define('DapBreakpointCondition', { text = '', texthl = 'DiagnosticSignWarn', linehl = '', numhl = '' }) fn.sign_define("DapBreakpointCondition", { text = "", texthl = "DiagnosticSignWarn", linehl = "", numhl = "" })
fn.sign_define('DapLogPoint', { text = '', texthl = 'DiagnosticSignInfo', linehl = '', numhl = '' }) fn.sign_define("DapLogPoint", { text = "", texthl = "DiagnosticSignInfo", linehl = "", numhl = "" })
fn.sign_define('DapStopped', { text = '', texthl = 'DiagnosticSignWarn', linehl = '', numhl = '' }) fn.sign_define("DapStopped", { text = "", texthl = "DiagnosticSignWarn", linehl = "", numhl = "" })
fn.sign_define('DapBreakpointReject', { text = '', texthl = 'DiagnosticSignHint', linehl = '', numhl = '' }) fn.sign_define("DapBreakpointReject", { text = "", texthl = "DiagnosticSignHint", linehl = "", numhl = "" })

View File

@ -1,5 +1,13 @@
local colors = require('tokyonight.colors').setup() local loaded, colors = pcall(require, "kanagawa.colors")
require('scrollbar').setup({ if not loaded then
return
end
local loaded, scrollbar = pcall(require, "scrollbar")
if not loaded then
return
end
scrollbar.setup({
handle = { handle = {
color = colors.bg_highlight, color = colors.bg_highlight,
}, },

View File

@ -1,8 +1,11 @@
local fidget = require('fidget') local loaded, fidget = pcall(require, "fidget")
if not loaded then
return
end
fidget.setup({ fidget.setup({
text = { text = {
spinner = 'dots', spinner = "dots",
}, },
window = { window = {
blend = 0, blend = 0,

View File

@ -1,4 +1,7 @@
local nvim_tree = require('nvim-tree.configs') local loaded, nvim_tree = pcall(require, "nvim-tree.configs")
if not loaded then
return
end
nvim_tree.setup({ nvim_tree.setup({
highlight = { highlight = {
@ -6,7 +9,7 @@ nvim_tree.setup({
additional_vim_regex_highlighting = true, additional_vim_regex_highlighting = true,
disable = { disable = {
-- Ansible support reasons -- Ansible support reasons
'ansible.yaml', "ansible.yaml",
}, },
}, },
matchup = { matchup = {

View File

@ -1,26 +1,29 @@
local hydra = require('hydra') local loaded, hydra = pcall(require, "hydra")
if not loaded then
return
end
-- Side Scroll -- Side Scroll
hydra({ hydra({
name = 'Side scroll', name = "Side scroll",
config = { config = {
{ {
position = 'bottom-right', position = "bottom-right",
border = 'rounded', border = "rounded",
}, },
}, },
mode = 'n', mode = "n",
body = 'z', body = "z",
heads = { heads = {
{ 'h', '5zh' }, { "h", "5zh" },
{ 'l', '5zl', { desc = '←/→' } }, { "l", "5zl", { desc = "←/→" } },
{ 'H', 'zH' }, { "H", "zH" },
{ 'L', 'zL', { desc = 'half screen ←/→' } }, { "L", "zL", { desc = "half screen ←/→" } },
}, },
}) })
-- Git Integration -- Git Integration
local gitsigns = require('gitsigns') local gitsigns = require("gitsigns")
local hint = [[ local hint = [[
_J_: next hunk _s_: stage hunk _d_: show deleted _b_: blame line _J_: next hunk _s_: stage hunk _d_: show deleted _b_: blame line
@ -33,11 +36,11 @@ local hint = [[
hydra({ hydra({
hint = hint, hint = hint,
config = { config = {
color = 'pink', color = "pink",
invoke_on_body = true, invoke_on_body = true,
hint = { hint = {
position = 'bottom-right', position = "bottom-right",
border = 'rounded', border = "rounded",
}, },
on_enter = function() on_enter = function()
vim.bo.modifiable = false vim.bo.modifiable = false
@ -50,68 +53,68 @@ hydra({
gitsigns.toggle_deleted(false) gitsigns.toggle_deleted(false)
end, end,
}, },
mode = { 'n', 'x' }, mode = { "n", "x" },
body = '<leader>G', body = "<leader>G",
heads = { heads = {
{ {
'J', "J",
function() function()
if vim.wo.diff then if vim.wo.diff then
return ']c' return "]c"
end end
vim.schedule(function() vim.schedule(function()
gitsigns.next_hunk() gitsigns.next_hunk()
end) end)
return '<Ignore>' return "<Ignore>"
end, end,
{ expr = true }, { expr = true },
}, },
{ {
'K', "K",
function() function()
if vim.wo.diff then if vim.wo.diff then
return '[c' return "[c"
end end
vim.schedule(function() vim.schedule(function()
gitsigns.prev_hunk() gitsigns.prev_hunk()
end) end)
return '<Ignore>' return "<Ignore>"
end, end,
{ expr = true }, { expr = true },
}, },
{ 's', ':Gitsigns stage_hunk<CR>', { silent = true } }, { "s", ":Gitsigns stage_hunk<CR>", { silent = true } },
{ 'u', gitsigns.undo_stage_hunk }, { "u", gitsigns.undo_stage_hunk },
{ 'S', gitsigns.stage_buffer }, { "S", gitsigns.stage_buffer },
{ 'p', gitsigns.preview_hunk }, { "p", gitsigns.preview_hunk },
{ 'd', gitsigns.toggle_deleted, { nowait = true } }, { "d", gitsigns.toggle_deleted, { nowait = true } },
{ 'b', gitsigns.blame_line }, { "b", gitsigns.blame_line },
{ {
'B', "B",
function() function()
gitsigns.blame_line({ full = true }) gitsigns.blame_line({ full = true })
end, end,
}, },
{ '/', gitsigns.show, { exit = true } }, -- show the base of the file { "/", gitsigns.show, { exit = true } }, -- show the base of the file
{ '<Enter>', '<cmd>Neogit<CR>', { exit = true } }, { "<Enter>", "<cmd>Neogit<CR>", { exit = true } },
{ 'q', nil, { exit = true, nowait = true } }, { "q", nil, { exit = true, nowait = true } },
}, },
}) })
-- Hydra to repeat expanding windows -- Hydra to repeat expanding windows
hydra({ hydra({
name = 'Window Sizing', name = "Window Sizing",
mode = 'n', mode = "n",
body = '<C-w>', body = "<C-w>",
config = { config = {
{ {
position = 'bottom-right', position = "bottom-right",
border = 'rounded', border = "rounded",
}, },
}, },
heads = { heads = {
{ '<', '2<C-w><' }, { "<", "2<C-w><" },
{ '>', '2<C-w>>', { desc = '←/→' } }, { ">", "2<C-w>>", { desc = "←/→" } },
{ '+', '2<C-w>+' }, { "+", "2<C-w>+" },
{ '-', '2<C-w>-', { desc = '↑/↓' } }, { "-", "2<C-w>-", { desc = "↑/↓" } },
}, },
}) })

View File

@ -1,24 +1,28 @@
local g = vim.g local g = vim.g
g.indent_blankline_char = '' g.indent_blankline_char = ""
g.indent_blankline_context_char = '' g.indent_blankline_context_char = ""
-- Disable indent-blankline on these pages. -- Disable indent-blankline on these pages.
g.indent_blankline_filetype_exclude = { g.indent_blankline_filetype_exclude = {
'help', "help",
'terminal', "terminal",
'alpha', "alpha",
'packer', "packer",
'lsp-installer', "lsp-installer",
'lspinfo', "lspinfo",
'mason.nvim', "mason.nvim",
} }
g.indent_blankline_buftype_exclude = { 'terminal' } g.indent_blankline_buftype_exclude = { "terminal" }
g.indent_blankline_show_trailing_blankline_indent = false g.indent_blankline_show_trailing_blankline_indent = false
g.indent_blankline_show_first_indent_level = true g.indent_blankline_show_first_indent_level = true
require('indent_blankline').setup({ local loaded, indent_blankline = pcall(require, "indent_blankline")
if not loaded then
return
end
indent_blankline.setup({
-- space_char_blankline = " ", -- space_char_blankline = " ",
show_current_context = true, show_current_context = true,
show_current_context_start = true, show_current_context_start = true,

View File

@ -1,6 +1,42 @@
local mason_lspconfig = require("mason-lspconfig") local loaded, mason_lspconfig = pcall(require, "mason-lspconfig")
local lspconfig = require("lspconfig") if not loaded then
local async = require("plenary.async") return
end
local lspconfig_loaded, lspconfig = pcall(require, "lspconfig")
if not lspconfig_loaded then
return
end
local plenary_loaded, async = pcall(require, "plenary.async")
if not plenary_loaded then
return
end
local cmp_nvim_lsp_loaded, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not cmp_nvim_lsp_loaded then
return
end
local rust_tools_loaded, rust_tools = pcall(require, "rust_tools")
if not rust_tools_loaded then
return
end
local lua_dev_loaded, lua_dev = pcall(require, "lua-dev")
if not lua_dev_loaded then
return
end
local sqls_loaded, sqls = pcall(require, "sqls")
if not sqls_loaded then
return
end
local chsarpls_extended_loaded, csharpls_extended = pcall(require, "csharpls_extended")
if not csharpls_extended_loaded then
return
end
-- NOTE: Keep this near top -- NOTE: Keep this near top
mason_lspconfig.setup({ mason_lspconfig.setup({
@ -18,7 +54,7 @@ local function on_attach(client, bufnr)
end) end)
end end
local lsp_capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) local lsp_capabilities = cmp_nvim_lsp.update_capabilities(vim.lsp.protocol.make_client_capabilities())
local opts = { local opts = {
capabilities = lsp_capabilities, capabilities = lsp_capabilities,
on_attach = on_attach, on_attach = on_attach,
@ -51,7 +87,7 @@ local rustopts = {
}, },
}, },
} }
require("rust-tools").setup(rustopts) rust_tools.setup(rustopts)
-- NOTE: ANSIBLE LSP -- NOTE: ANSIBLE LSP
-- I use ansible a lot, define exceptions for servers that can use -- I use ansible a lot, define exceptions for servers that can use
@ -79,7 +115,7 @@ lspconfig.ansiblels.setup({
}) })
-- NOTE: LUA LSP -- NOTE: LUA LSP
local luadev = require("lua-dev").setup({ local luadev = lua_dev.setup({
lspconfig = opts, lspconfig = opts,
}) })
@ -88,7 +124,7 @@ lspconfig.sumneko_lua.setup(luadev)
-- NOTE: SQL LSP -- NOTE: SQL LSP
lspconfig.sqls.setup({ lspconfig.sqls.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
require("sqls").on_attach(client, bufnr) sqls.on_attach(client, bufnr)
on_attach(client, bufnr) on_attach(client, bufnr)
end, end,
}) })
@ -157,7 +193,7 @@ lspconfig.yamlls.setup({
lspconfig.csharp_ls.setup({ lspconfig.csharp_ls.setup({
handlers = { handlers = {
["textDocument/definition"] = require("csharpls_extended").handler, ["textDocument/definition"] = csharpls_extended.handler,
}, },
capabilities = lsp_capabilities, capabilities = lsp_capabilities,
on_attach = on_attach, on_attach = on_attach,

View File

@ -1,4 +1,7 @@
local neotree = require('neo-tree') local loaded, neotree = pcall(require, "neo-tree")
if not loaded then
return
end
vim.g.neo_tree_remove_legacy_commands = 1 vim.g.neo_tree_remove_legacy_commands = 1
neotree.setup({ neotree.setup({
@ -7,8 +10,8 @@ neotree.setup({
}, },
window = { window = {
mappings = { mappings = {
['/'] = 'noop', ["/"] = "noop",
['/'] = {}, ["/"] = {},
}, },
}, },
}) })

View File

@ -1,9 +1,12 @@
local null_ls = require('null-ls') local loaded, null_ls = pcall(require, "null-ls")
if not loaded then
return
end
null_ls.setup({ null_ls.setup({
sources = { sources = {
null_ls.builtins.formatting.shfmt.with({ null_ls.builtins.formatting.shfmt.with({
extra_args = { '-i 4' }, extra_args = { "-i 4" },
}), }),
null_ls.builtins.diagnostics.shellcheck, null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.code_actions.shellcheck, null_ls.builtins.code_actions.shellcheck,

View File

@ -1,3 +1,6 @@
local colorizer = require('colorizer') local loaded, colorizer = pcall(require, "colorizer")
if not loaded then
return
end
colorizer.setup({}) colorizer.setup({})
vim.cmd('ColorizerAttachToBuffer') vim.cmd("ColorizerAttachToBuffer")

View File

@ -1,6 +1,10 @@
require('notify').setup({ local loaded, notify = pcall(require, "notify")
if not loaded then
return
end
notify.setup({
-- Animation style (see below for details) -- Animation style (see below for details)
stages = 'fade_in_slide_out', stages = "fade_in_slide_out",
-- Function called when a new window is opened, use for changing win settings/config -- Function called when a new window is opened, use for changing win settings/config
on_open = nil, on_open = nil,
@ -9,26 +13,26 @@ require('notify').setup({
on_close = nil, on_close = nil,
-- 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 = 5000, timeout = 5000,
-- 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, an RGB hex value e.g. "#000000" or a function returning an RGB code for dynamic values -- Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function returning an RGB code for dynamic values
background_colour = '#000000', background_colour = "#000000",
-- Minimum width for notification windows -- Minimum width for notification windows
minimum_width = 50, minimum_width = 50,
-- Icons for the different levels -- Icons for the different levels
icons = { icons = {
ERROR = '', ERROR = "",
WARN = '', WARN = "",
INFO = '', INFO = "",
DEBUG = '', DEBUG = "",
TRACE = '', TRACE = "",
}, },
}) })
vim.notify = require('notify') vim.notify = require("notify")

View File

@ -1,3 +1,6 @@
local dap_python = require('dap-python') local loaded, dap_python = pcall(require, "dap-python")
dap_python.setup('~/.venvs/debugpy/bin/python') if not loaded then
dap_python.test_runner = 'pytest' return
end
dap_python.setup("~/.venvs/debugpy/bin/python")
dap_python.test_runner = "pytest"

View File

@ -1,4 +1,7 @@
local telescope = require("telescope") local loaded, telescope = pcall(require, "telescope")
if not loaded then
return
end
local actions = require("telescope.actions") local actions = require("telescope.actions")
telescope.setup({ telescope.setup({

View File

@ -1 +1,5 @@
require('todo-comments').setup({}) local loaded, todo_comments = pcall(require, "todo-comments")
if not loaded then
return
end
todo_comments.setup({})

View File

@ -1,7 +0,0 @@
local g = vim.g
g.tokyonight_style = 'night'
g.tokyonight_transparent = true
g.tokyonight_transparent_sidebar = true
vim.cmd('colorscheme tokyonight')

View File

@ -1,13 +1,16 @@
local nvim_treesitter = require('nvim-treesitter.configs') local loaded, nvim_treesitter = pcall(require, "nvim-treesitter.configs")
if not loaded then
return
end
nvim_treesitter.setup({ nvim_treesitter.setup({
ensure_installed = { ensure_installed = {
'norg', "norg",
}, },
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting = true, additional_vim_regex_highlighting = true,
disable = { 'yaml' }, disable = { "yaml" },
}, },
matchup = { matchup = {
enable = true, enable = true,