trying to fix shit
This commit is contained in:
parent
198712a432
commit
a9bd52c819
42 changed files with 3 additions and 2464 deletions
|
@ -1,3 +0,0 @@
|
|||
TODO: set nvim-surround, nvim-cmp, vimtex keybinds separately from plugin setup
|
||||
TODO: continue work on latex snippets
|
||||
FIX: Closing keybind needs to account for the vimtex error window
|
|
@ -1,8 +0,0 @@
|
|||
require('impatient')
|
||||
require('config.options')
|
||||
require('funcs').bootstrap()
|
||||
require('plugins')
|
||||
require('config.autocmds').setup()
|
||||
require('config.filetypes').setup()
|
||||
require('config.icons').setup()
|
||||
require('config.keymaps').map('general')
|
|
@ -1,122 +0,0 @@
|
|||
local M = {}
|
||||
M.list = {
|
||||
{ -- Handles the automatic line numeration changes
|
||||
{ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" },
|
||||
{
|
||||
pattern = "*",
|
||||
command = "if &nu && mode() != \"i\" | set rnu | endif"
|
||||
}
|
||||
},
|
||||
{ -- Handles the automatic line numeration changes
|
||||
{ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" },
|
||||
{
|
||||
pattern = "*",
|
||||
command = "if &nu | set nornu | endif"
|
||||
}
|
||||
},
|
||||
{
|
||||
"BufWritePost",
|
||||
{
|
||||
pattern = { "bm-files", "bm-dirs" },
|
||||
command = "!shortcuts"
|
||||
}
|
||||
},
|
||||
{
|
||||
{ "BufRead", "BufNewFile" },
|
||||
{
|
||||
pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" },
|
||||
command = "set filetype=xdefaults"
|
||||
}
|
||||
},
|
||||
{
|
||||
"BufWritePost",
|
||||
{
|
||||
pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" },
|
||||
command = "!xrdb %"
|
||||
}
|
||||
},
|
||||
{
|
||||
"BufWritePost",
|
||||
{
|
||||
pattern = "*/dwmblocks/config.h",
|
||||
command = "!cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }"
|
||||
}
|
||||
},
|
||||
{
|
||||
"BufWritePost",
|
||||
{
|
||||
pattern = "*.java",
|
||||
callback = function()
|
||||
vim.lsp.codelens.refresh()
|
||||
end
|
||||
}
|
||||
},
|
||||
-- {
|
||||
-- { "BufDelete", "VimLeave" },
|
||||
-- {
|
||||
-- pattern = "*.tex",
|
||||
-- command = "!texclear \"%:p\""
|
||||
-- }
|
||||
-- },
|
||||
{ -- Use 'q' to quit from common plugins
|
||||
'FileType',
|
||||
{
|
||||
pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" },
|
||||
callback = function()
|
||||
vim.cmd [[
|
||||
nnoremap <silent> <buffer> q :close<CR>
|
||||
set nobuflisted
|
||||
]]
|
||||
end
|
||||
}
|
||||
},
|
||||
{
|
||||
'Filetype',
|
||||
{
|
||||
pattern = { "gitcommit", "markdown" },
|
||||
callback = function()
|
||||
vim.opt_local.wrap = true
|
||||
vim.opt_local.spell = true
|
||||
end,
|
||||
}
|
||||
},
|
||||
{ -- Automatically apply changes to plugins.lua
|
||||
'BufWritePost',
|
||||
{
|
||||
group = 'packer_user_config',
|
||||
pattern = { "plugins.lua", "pluginlist.lua" },
|
||||
command = "source <afile> | PackerCompile"
|
||||
}
|
||||
},
|
||||
{ -- Fix auto comment
|
||||
'BufWinEnter',
|
||||
{
|
||||
command = "set formatoptions-=cro"
|
||||
}
|
||||
},
|
||||
{ -- Highlight yanked text
|
||||
'TextYankPost',
|
||||
{
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function M.setup()
|
||||
vim.api.nvim_create_augroup('user_config', { clear = true })
|
||||
for _, entry in ipairs(M.list) do
|
||||
local event = entry[1]
|
||||
local opts = entry[2]
|
||||
if type(opts.group) == "string" and opts.group ~= "" then
|
||||
local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group })
|
||||
if not exists then
|
||||
vim.api.nvim_create_augroup(opts.group, {})
|
||||
end
|
||||
end
|
||||
vim.api.nvim_create_autocmd(event, opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,33 +0,0 @@
|
|||
local M = {}
|
||||
M.list = {
|
||||
{
|
||||
extension = {
|
||||
yml = function(path, bufnr)
|
||||
if vim.fs.find({ 'tasks', 'roles', 'handlers', 'group_vars', 'host_vars' },
|
||||
{ type = 'directory', upward = true }) and
|
||||
vim.fs.find({ 'ansible.cfg', '.ansible-lint' }, { upward = true }) then
|
||||
return 'yaml.ansible'
|
||||
else
|
||||
return 'yaml'
|
||||
end
|
||||
end,
|
||||
yaml = function(path, bufnr)
|
||||
if vim.fs.find({ 'tasks', 'roles', 'handlers', 'group_vars', 'host_vars' },
|
||||
{ type = 'directory', upward = true }) and
|
||||
vim.fs.find({ 'ansible.cfg', '.ansible-lint' }, { upward = true }) then
|
||||
return 'yaml.ansible'
|
||||
else
|
||||
return 'yaml'
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
M.setup = function()
|
||||
for _, entry in pairs(M.list) do
|
||||
vim.filetype.add(entry)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,174 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
M.list = {
|
||||
kind = {
|
||||
Array = "",
|
||||
Boolean = "蘒",
|
||||
Class = "",
|
||||
Color = "",
|
||||
Constant = "",
|
||||
Constructor = "",
|
||||
Enum = "",
|
||||
EnumMember = "",
|
||||
Event = "",
|
||||
Field = "",
|
||||
File = "",
|
||||
Folder = "",
|
||||
Function = "",
|
||||
Interface = "",
|
||||
Key = "",
|
||||
Keyword = "",
|
||||
Method = "",
|
||||
Module = "",
|
||||
Namespace = "",
|
||||
Null = "ﳠ",
|
||||
Number = "",
|
||||
Object = "",
|
||||
Operator = "",
|
||||
Package = "",
|
||||
Property = "",
|
||||
Reference = "",
|
||||
Snippet = "",
|
||||
String = "",
|
||||
Struct = "",
|
||||
Text = "",
|
||||
TypeParameter = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Variable = "",
|
||||
},
|
||||
git = {
|
||||
LineAdded = "",
|
||||
LineModified = "",
|
||||
LineRemoved = "",
|
||||
FileDeleted = "",
|
||||
FileIgnored = "",
|
||||
FileRenamed = "",
|
||||
FileStaged = "S",
|
||||
FileUnmerged = "",
|
||||
FileUnstaged = "",
|
||||
FileUntracked = "U",
|
||||
Diff = "",
|
||||
Repo = "",
|
||||
Octoface = "",
|
||||
Branch = "",
|
||||
},
|
||||
ui = {
|
||||
ArrowCircleDown = "",
|
||||
ArrowCircleLeft = "",
|
||||
ArrowCircleRight = "",
|
||||
ArrowCircleUp = "",
|
||||
BoldArrowDown = "",
|
||||
BoldArrowLeft = "",
|
||||
BoldArrowRight = "",
|
||||
BoldArrowUp = "",
|
||||
BoldClose = "",
|
||||
BoldDividerLeft = "",
|
||||
BoldDividerRight = "",
|
||||
BoldLineLeft = "▎",
|
||||
BookMark = "",
|
||||
BoxChecked = "",
|
||||
Bug = "",
|
||||
Stacks = " ",
|
||||
Scopes = "",
|
||||
Watches = "",
|
||||
DebugConsole = " ",
|
||||
Calendar = "",
|
||||
Check = "",
|
||||
ChevronRight = ">",
|
||||
ChevronShortDown = "",
|
||||
ChevronShortLeft = "",
|
||||
ChevronShortRight = "",
|
||||
ChevronShortUp = "",
|
||||
Circle = "",
|
||||
Close = "",
|
||||
CloudDownload = "",
|
||||
Code = "",
|
||||
Comment = "",
|
||||
Dashboard = "",
|
||||
DividerLeft = "",
|
||||
DividerRight = "",
|
||||
DoubleChevronRight = "",
|
||||
DoubleChevronLeft = "",
|
||||
Ellipsis = "…",
|
||||
EmptyFolder = "",
|
||||
EmptyFolderOpen = "",
|
||||
File = "",
|
||||
FileSymlink = "",
|
||||
Files = "",
|
||||
FindFile = "",
|
||||
FindText = "",
|
||||
Fire = "",
|
||||
Folder = "",
|
||||
FolderOpen = "",
|
||||
FolderSymlink = "",
|
||||
Forward = "",
|
||||
Gear = "",
|
||||
History = "",
|
||||
Lightbulb = "",
|
||||
LineLeft = "▏",
|
||||
LineMiddle = "│",
|
||||
List = "",
|
||||
Lock = "",
|
||||
MinusCircle = "",
|
||||
NewFile = "",
|
||||
Note = "",
|
||||
Package = "",
|
||||
Pencil = "",
|
||||
Plus = "",
|
||||
Project = "",
|
||||
Search = "",
|
||||
SignIn = "",
|
||||
SignOut = "",
|
||||
Tab = "",
|
||||
Table = "",
|
||||
Target = "",
|
||||
Telescope = "",
|
||||
Text = "",
|
||||
Tree = "",
|
||||
Triangle = "契",
|
||||
TriangleShortArrowDown = "",
|
||||
TriangleShortArrowLeft = "",
|
||||
TriangleShortArrowRight = "",
|
||||
TriangleShortArrowUp = "",
|
||||
},
|
||||
diagnostics = {
|
||||
BoldError = "",
|
||||
Error = "",
|
||||
BoldWarning = "",
|
||||
Warning = "",
|
||||
BoldInformation = "",
|
||||
Information = "",
|
||||
BoldQuestion = "",
|
||||
Question = "",
|
||||
BoldHint = "",
|
||||
Hint = "",
|
||||
Debug = "",
|
||||
Trace = "✎",
|
||||
},
|
||||
progress = { "", "", "", "", "", "", "", "", "", "", "", "", "" },
|
||||
misc = {
|
||||
Robot = "ﮧ",
|
||||
Squirrel = "",
|
||||
Tag = "",
|
||||
Watch = "",
|
||||
Smiley = "ﲃ",
|
||||
Package = "",
|
||||
CircuitBoard = "",
|
||||
},
|
||||
}
|
||||
M.setup = function()
|
||||
local icons = M.list.diagnostics
|
||||
local signs = {
|
||||
DiagnosticSignError = icons.BoldError,
|
||||
DiagnosticSignWarn = icons.BoldWarning,
|
||||
DiagnosticSignHint = icons.BoldHint,
|
||||
DiagnosticSignInfo = icons.BoldInformation
|
||||
}
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,211 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
local maps = {
|
||||
general = {
|
||||
n = {
|
||||
-- Navigate buffers
|
||||
{ "<C-l>", ":bnext<CR>" },
|
||||
{ "<C-h>", ":bprevious<CR>" },
|
||||
-- lsp
|
||||
{ "gD", vim.lsp.buf.declaration },
|
||||
{ "gd", vim.lsp.buf.definition },
|
||||
{ "K", vim.lsp.buf.hover },
|
||||
{ "gI", vim.lsp.buf.implementation },
|
||||
{ "gr", vim.lsp.buf.references },
|
||||
{ "gl", vim.diagnostic.open_float },
|
||||
},
|
||||
i = {
|
||||
-- Delete last word with ctrl + del
|
||||
{ "<C-BS>", "<C-W>" },
|
||||
},
|
||||
v = {
|
||||
-- Better paste
|
||||
{ "p", '"_dP' },
|
||||
-- Stay in indent mode
|
||||
{ "<", "<gv" },
|
||||
{ ">", ">gv" },
|
||||
}
|
||||
},
|
||||
bufferline = {
|
||||
n = {
|
||||
{ "<C-l>", "<cmd>BufferLineCycleNext<CR>" },
|
||||
{ "<C-h>", "<cmd>BufferLineCyclePrev<CR>" },
|
||||
{ "<A-l>", "<cmd>BufferLineMoveNext<CR>" },
|
||||
{ "<A-h>", "<cmd>BufferLineMovePrev<CR>" },
|
||||
}
|
||||
},
|
||||
blankline = {
|
||||
n = {
|
||||
{ "<c-c>",
|
||||
function()
|
||||
local ok, start = require("indent_blankline.utils").get_current_context(
|
||||
vim.g.indent_blankline_context_patterns,
|
||||
vim.g.indent_blankline_use_treesitter_scope
|
||||
)
|
||||
if ok then
|
||||
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
||||
vim.cmd [[normal! _]]
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
local wkmaps = {
|
||||
general = {
|
||||
n = {
|
||||
["w"] = { "<cmd>w!<CR>", "Save" },
|
||||
["q"] = { require("funcs").buf_kill, "Close" },
|
||||
["h"] = { "<cmd>nohlsearch<CR>", "Clear Highlights" },
|
||||
["n"] = { "<cmd>ene<CR>", "New File" },
|
||||
u = {
|
||||
name = "Utility",
|
||||
c = { "<cmd>w!<CR><cmd>!compiler \"%:p\"<CR>", "Compile" },
|
||||
},
|
||||
l = {
|
||||
name = "LSP",
|
||||
a = { vim.lsp.buf.code_action, "Code Action" },
|
||||
f = { function() require("funcs").format({ async = true }) end, "Format" },
|
||||
j = { vim.diagnostic.goto_next, "Next Diagnostic" },
|
||||
k = { vim.diagnostic.goto_prev, "Prev Diagnostic" },
|
||||
l = { vim.lsp.codelens.run, "CodeLens Action" },
|
||||
q = { vim.diagnostic.setloclist, "Quickfix" },
|
||||
r = { vim.lsp.buf.rename, "Rename" },
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
lspconfig = {
|
||||
n = {
|
||||
l = {
|
||||
name = "LSP",
|
||||
i = { "<cmd>LspInfo<cr>", "LSP Info" },
|
||||
}
|
||||
}
|
||||
},
|
||||
mason = {
|
||||
n = {
|
||||
l = {
|
||||
name = "LSP",
|
||||
I = { "<cmd>Mason<cr>", "Mason Info" },
|
||||
}
|
||||
}
|
||||
},
|
||||
dap = {
|
||||
n = {
|
||||
d = {
|
||||
name = "DAP",
|
||||
b = { require("dap").toggle_breakpoint, "Toggle Breakpoint" },
|
||||
c = { require("dap").continue, "Continue" },
|
||||
i = { require("dap").step_into, "Step Into" },
|
||||
o = { require("dap").step_over, "Step Over" },
|
||||
O = { require("dap").step_out, "Step Out" },
|
||||
r = { require("dap").repl.toggle, "Toggle REPL" },
|
||||
l = { require("dap").run_last, "Run Last" },
|
||||
t = { require("dap").terminate, "Stop Debugger" },
|
||||
u = { require("dapui").toggle, "Toggle DAP UI" },
|
||||
}
|
||||
}
|
||||
},
|
||||
bufferline = {
|
||||
n = {
|
||||
b = {
|
||||
name = "Buffers",
|
||||
g = { "<cmd>BufferLinePick<CR>", "Goto" },
|
||||
e = { "<cmd>BufferLinePickClose<CR>", "Pick which buffer to close" },
|
||||
h = { "<cmd>BufferLineCloseLeft<CR>", "Close all to the left" },
|
||||
l = { "<cmd>BufferLineCloseRight<CR>", "Close all to the right" },
|
||||
D = { "<cmd>BufferLineSortByDirectory<CR>", "Sort by directory" },
|
||||
L = { "<cmd>BufferLineSortByExtension<CR>", "Sort by extension" },
|
||||
},
|
||||
}
|
||||
},
|
||||
packer = {
|
||||
n = {
|
||||
p = {
|
||||
name = "Packer",
|
||||
c = { "<cmd>PackerCompile<CR>", "Compile" },
|
||||
C = { "<cmd>PackerClean<CR>", "Clean" },
|
||||
i = { "<cmd>PackerInstall<CR>", "Install" },
|
||||
s = { "<cmd>PackerSync<CR>", "Sync" },
|
||||
S = { "<cmd>PackerStatus<CR>", "Status" },
|
||||
u = { "<cmd>PackerUpdate<CR>", "Update" },
|
||||
},
|
||||
}
|
||||
},
|
||||
lf = {
|
||||
n = {
|
||||
["e"] = { require("lf").start, "File Picker" },
|
||||
}
|
||||
},
|
||||
treesitter = {
|
||||
n = {
|
||||
T = {
|
||||
name = "Treesitter",
|
||||
i = { "<cmd>TSConfigInfo<cr>", "Info" },
|
||||
},
|
||||
}
|
||||
},
|
||||
comment = {
|
||||
n = {
|
||||
["/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment toggle current line" },
|
||||
},
|
||||
v = {
|
||||
["/"] = { "<Plug>(comment_toggle_linewise_visual)", "Comment toggle linewise" },
|
||||
},
|
||||
},
|
||||
gitsigns = {
|
||||
n = {
|
||||
g = {
|
||||
name = "Git",
|
||||
j = { require("gitsigns").next_hunk, "Next Hunk" },
|
||||
k = { require("gitsigns").prev_hunk, "Prev Hunk" },
|
||||
l = { require("gitsigns").blame_line, "Blame" },
|
||||
p = { require("gitsigns").preview_hunk, "Preview Hunk" },
|
||||
r = { require("gitsigns").reset_hunk, "Reset Hunk" },
|
||||
R = { require("gitsigns").reset_buffer, "Reset Buffer" },
|
||||
s = { require("gitsigns").stage_hunk, "Stage Hunk" },
|
||||
u = { require("gitsigns").undo_stage_hunk, "Undo Stage Hunk" },
|
||||
d = { "<cmd>Gitsigns diffthis HEAD<cr>", "Git Diff" },
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local wk_ok, whichkey = pcall(require, 'which-key')
|
||||
|
||||
M.map = function(section)
|
||||
if maps[section] then
|
||||
for mode, binds in pairs(maps[section]) do
|
||||
for _, bind in pairs(binds) do
|
||||
local key = bind[1]
|
||||
local cmd = ""
|
||||
local opt = { silent = true, noremap = true }
|
||||
if type(bind[2]) == "string" then
|
||||
cmd = bind[2]
|
||||
elseif type(bind[2]) == "function" then
|
||||
opt["callback"] = bind[2]
|
||||
end
|
||||
vim.api.nvim_set_keymap(mode, key, cmd, opt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if wk_ok then
|
||||
if wkmaps[section] then
|
||||
for mode, binds in pairs(wkmaps[section]) do
|
||||
whichkey.register(binds, {
|
||||
mode = mode,
|
||||
prefix = "<leader>",
|
||||
buffer = nil,
|
||||
silent = true,
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,55 +0,0 @@
|
|||
local o = vim.opt
|
||||
local g = vim.g
|
||||
|
||||
g.mapleader = " "
|
||||
g.maplocalleader = " "
|
||||
|
||||
o.undodir = vim.fn.stdpath "cache" .. "/undo"
|
||||
o.clipboard = "unnamedplus"
|
||||
o.conceallevel = 0
|
||||
o.numberwidth = 3
|
||||
o.hlsearch = true
|
||||
o.ignorecase = true
|
||||
o.showmode = false
|
||||
o.smartindent = true
|
||||
o.splitbelow = true
|
||||
o.splitbelow = true
|
||||
o.splitbelow = true
|
||||
o.updatetime = 250
|
||||
o.writebackup = false
|
||||
o.expandtab = true
|
||||
o.shiftwidth = 4
|
||||
o.tabstop = 4
|
||||
o.cursorline = true
|
||||
o.signcolumn = "yes"
|
||||
o.wrap = false
|
||||
o.scrolloff = 8
|
||||
o.sidescrolloff = 8
|
||||
o.undofile = true
|
||||
o.title = true
|
||||
o.titlestring = " %t"
|
||||
o.termguicolors = true
|
||||
o.timeoutlen = 500
|
||||
o.foldmethod = "expr"
|
||||
o.foldlevelstart = 99
|
||||
o.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
o.number = true
|
||||
o.relativenumber = true
|
||||
o.laststatus = 3
|
||||
o.modeline = true
|
||||
o.modelines = 3
|
||||
o.listchars = "eol:$,tab:>-,trail:~,extends:>,precedes:<"
|
||||
|
||||
local icons = require('config.icons').list
|
||||
|
||||
local signs = {
|
||||
DiagnosticSignError = icons.BoldError,
|
||||
DiagnosticSignWarn = icons.BoldWarning,
|
||||
DiagnosticSignHint = icons.BoldHint,
|
||||
DiagnosticSignInfo = icons.BoldInformation
|
||||
}
|
||||
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
|
@ -1,117 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
function M.bootstrap()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
|
||||
print "Cloning Packer..."
|
||||
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
|
||||
vim.cmd "packadd packer.nvim"
|
||||
require "plugins"
|
||||
vim.cmd "PackerSync"
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "PackerComplete",
|
||||
callback = function()
|
||||
vim.cmd "bw | silent! MasonInstallAll" -- close packer window
|
||||
require("packer").loader "nvim-treesitter"
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function M.format_filter(client)
|
||||
local filetype = vim.bo.filetype
|
||||
local n = require "null-ls"
|
||||
local s = require "null-ls.sources"
|
||||
local method = n.methods.FORMATTING
|
||||
local available_formatters = s.get_available(filetype, method)
|
||||
|
||||
if #available_formatters > 0 then
|
||||
return client.name == "null-ls"
|
||||
elseif client.supports_method "textDocument/formatting" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function M.format(opts)
|
||||
opts = opts or {}
|
||||
opts.filter = opts.filter or M.format_filter
|
||||
return vim.lsp.buf.format(opts)
|
||||
end
|
||||
|
||||
-- Modified version of a function stolen from LunarVim
|
||||
function M.buf_kill(kill_command, bufnr, force)
|
||||
kill_command = kill_command or "bd"
|
||||
|
||||
local bo = vim.bo
|
||||
local api = vim.api
|
||||
local fmt = string.format
|
||||
local fnamemodify = vim.fn.fnamemodify
|
||||
|
||||
if bufnr == 0 or bufnr == nil then
|
||||
bufnr = api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
local bufname = api.nvim_buf_get_name(bufnr)
|
||||
|
||||
if not force then
|
||||
local warning
|
||||
if bo[bufnr].modified then
|
||||
warning = fmt([[No write since last change for (%s)]], fnamemodify(bufname, ":t"))
|
||||
elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then
|
||||
warning = fmt([[Terminal %s will be killed]], bufname)
|
||||
end
|
||||
if warning then
|
||||
vim.ui.input({
|
||||
prompt = string.format([[%s. Close it anyway? [y]es or [n]o (default: no): ]], warning),
|
||||
}, function(choice)
|
||||
if choice:match "ye?s?" then force = true end
|
||||
end)
|
||||
if not force then return end
|
||||
end
|
||||
end
|
||||
|
||||
-- Get list of windows IDs with the buffer to close
|
||||
local windows = vim.tbl_filter(function(win)
|
||||
return api.nvim_win_get_buf(win) == bufnr
|
||||
end, api.nvim_list_wins())
|
||||
|
||||
if #windows == 0 then return end
|
||||
|
||||
if force then
|
||||
kill_command = kill_command .. "!"
|
||||
end
|
||||
|
||||
-- Get list of active buffers
|
||||
local buffers = vim.tbl_filter(function(buf)
|
||||
return api.nvim_buf_is_valid(buf) and bo[buf].buflisted
|
||||
end, api.nvim_list_bufs())
|
||||
|
||||
-- If there is only one buffer (which has to be the current one), vim will
|
||||
-- create a new buffer on :bd.
|
||||
-- For more than one buffer, pick the previous buffer (wrapping around if necessary)
|
||||
if #buffers > 1 then
|
||||
for i, v in ipairs(buffers) do
|
||||
if v == bufnr then
|
||||
local prev_buf_idx = i == 1 and (#buffers - 1) or (i - 1)
|
||||
local prev_buffer = buffers[prev_buf_idx]
|
||||
for _, win in ipairs(windows) do
|
||||
api.nvim_win_set_buf(win, prev_buffer)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
vim.cmd('q!')
|
||||
end
|
||||
|
||||
-- Check if buffer still exists, to ensure the target buffer wasn't killed
|
||||
-- due to options like bufhidden=wipe.
|
||||
if api.nvim_buf_is_valid(bufnr) and bo[bufnr].buflisted then
|
||||
vim.cmd(string.format("%s %d", kill_command, bufnr))
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
|
@ -1,53 +0,0 @@
|
|||
local status_ok, alpha = pcall(require, 'alpha')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local dashboard = require('alpha.themes.dashboard')
|
||||
local icons = require('config.icons').list
|
||||
|
||||
local banner = {
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣶⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀",
|
||||
"⠀⣀⣴⣶⣶⣶⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀",
|
||||
"⣰⣿⣿⠿⠛⠿⢿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀",
|
||||
"⣿⣿⡇⠀⠀⠀⠀⠈⠛⢿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀",
|
||||
"⠹⣿⣧⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⡿⠛⠉⠀⢀⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀",
|
||||
"⠀⠙⢿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⣤⣶⣿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠉⠻⠷⡄⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠉⠀⢀⣠⣤⣤⣄⡀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣷⡀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⡀⠀⠀⠀⠀⣿⠟⠉⠉⠙⢿⣿⣿⣷",
|
||||
"⠀⠀⠀⣀⣠⣤⣤⣤⣶⣶⣶⣤⣤⠀⣴⣿⣿⣿⡿⠟⠛⠛⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠉⠀⠀⠀⢀⣼⣿⣿⡿",
|
||||
"⠀⠀⠀⠈⠉⠉⠉⠉⠉⠉⠛⠻⠏⣼⣿⣿⡿⣋⣀⣤⣤⣴⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣀⣠⣴⣾⣿⣿⡿⠁",
|
||||
"⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡿⠋⠘⠿⠟⠛⠛⢻⣿⣿⣿⠋⠁⠈⠉⢿⣿⣿⣧⠀⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠉⠀⠀",
|
||||
"⠙⣷⣤⣀⠀⠀⠀⢀⣀⣤⣶⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡟⠀⠀⠀⢠⣿⣿⣿⡟⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠈⠛⠿⢿⣿⣿⣿⠿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⡀⠀⢠⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣷⣶⣶⣶⣶⣦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣙⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⢶⣦⣤⣶⣾⣿⣿⡶⠈⠉⠛⠿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⣶⡿⠿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
|
||||
}
|
||||
|
||||
if vim.o.lines < 36 then
|
||||
banner = vim.list_slice(banner, 16, 22)
|
||||
end
|
||||
|
||||
dashboard.section.header.val = banner
|
||||
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("n", icons.ui.NewFile .. " New file", "<CMD>ene<CR>"),
|
||||
dashboard.button("e", icons.ui.FindFile .. " Open file", "<CMD>Lf<CR>"),
|
||||
dashboard.button("q", icons.ui.SignOut .. " Quit", "<CMD>qa<CR>"),
|
||||
}
|
||||
|
||||
dashboard.section.footer.val = "Behold: a Snail's Vim"
|
||||
|
||||
dashboard.section.footer.opts.hl = "Type"
|
||||
dashboard.section.header.opts.hl = "Include"
|
||||
dashboard.section.buttons.opts.hl = "Keyword"
|
||||
|
||||
-- dashboard.opts.opts.noautocmd = true
|
||||
alpha.setup(dashboard.opts)
|
|
@ -1,21 +0,0 @@
|
|||
local status_ok, autopairs = pcall(require, "nvim-autopairs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
autopairs.setup({
|
||||
check_ts = true,
|
||||
disable_filetype = { "TelescopePrompt", "vim" },
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
javascript = { "string", "template_string" },
|
||||
java = false,
|
||||
},
|
||||
})
|
||||
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
|
@ -1,143 +0,0 @@
|
|||
local status_ok, bufferline = pcall(require, "bufferline")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local colors = require('tokyonight.colors').setup({ transform = true })
|
||||
local icons = require('config.icons').list
|
||||
|
||||
local function is_ft(b, ft)
|
||||
return vim.bo[b].filetype == ft
|
||||
end
|
||||
|
||||
local function diagnostics_indicator(_, _, diagnostics, _)
|
||||
local result = {}
|
||||
local symbols = {
|
||||
error = icons.diagnostics.Error,
|
||||
warning = icons.diagnostics.Warning,
|
||||
info = icons.diagnostics.Information,
|
||||
}
|
||||
for name, count in pairs(diagnostics) do
|
||||
if symbols[name] and count > 0 then
|
||||
table.insert(result, symbols[name] .. " " .. count)
|
||||
end
|
||||
end
|
||||
result = table.concat(result, " ")
|
||||
return #result > 0 and result or ""
|
||||
end
|
||||
|
||||
local function custom_filter(buf, buf_nums)
|
||||
local logs = vim.tbl_filter(function(b)
|
||||
return is_ft(b, "log")
|
||||
end, buf_nums)
|
||||
if vim.tbl_isempty(logs) then
|
||||
return true
|
||||
end
|
||||
local tab_num = vim.fn.tabpagenr()
|
||||
local last_tab = vim.fn.tabpagenr "$"
|
||||
local is_log = is_ft(buf, "log")
|
||||
if last_tab == 1 then
|
||||
return true
|
||||
end
|
||||
-- only show log buffers in secondary tabs
|
||||
return (tab_num == last_tab and is_log) or (tab_num ~= last_tab and not is_log)
|
||||
end
|
||||
|
||||
local config = {
|
||||
highlights = {
|
||||
background = {
|
||||
italic = true,
|
||||
bold = false,
|
||||
},
|
||||
buffer_selected = {
|
||||
italic = false,
|
||||
bold = true,
|
||||
},
|
||||
},
|
||||
options = {
|
||||
mode = "buffers", -- set to "tabs" to only show tabpages instead
|
||||
numbers = "none", -- can be "none" | "ordinal" | "buffer_id" | "both" | function
|
||||
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
|
||||
right_mouse_command = "vert sbuffer %d", -- can be a string | function, see "Mouse actions"
|
||||
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
|
||||
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
|
||||
indicator = {
|
||||
-- icon = icons.ui.DoubleChevronRight, -- this should be omitted if indicator style is not 'icon'
|
||||
style = "none", -- can also be 'underline'|'none',
|
||||
},
|
||||
buffer_close_icon = icons.ui.Close,
|
||||
modified_icon = icons.ui.Circle,
|
||||
close_icon = icons.ui.BoldClose,
|
||||
left_trunc_marker = icons.ui.ArrowCircleLeft,
|
||||
right_trunc_marker = icons.ui.ArrowCircleRight,
|
||||
--- name_formatter can be used to change the buffer's label in the bufferline.
|
||||
--- Please note some names can/will break the
|
||||
--- bufferline so use this at your discretion knowing that it has
|
||||
--- some limitations that will *NOT* be fixed.
|
||||
name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
|
||||
-- remove extension from markdown files for example
|
||||
if buf.name:match "%.md" then
|
||||
return vim.fn.fnamemodify(buf.name, ":t:r")
|
||||
end
|
||||
end,
|
||||
max_name_length = 18,
|
||||
max_prefix_length = 15, -- prefix used when a buffer is de-duplicated
|
||||
truncate_names = true, -- whether or not tab names should be truncated
|
||||
tab_size = 18,
|
||||
diagnostics = "nvim_lsp",
|
||||
diagnostics_update_in_insert = false,
|
||||
diagnostics_indicator = diagnostics_indicator,
|
||||
-- NOTE: this will be called a lot so don't do any heavy processing here
|
||||
custom_filter = custom_filter,
|
||||
offsets = {
|
||||
{
|
||||
filetype = "undotree",
|
||||
text = "Undotree",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
{
|
||||
filetype = "NvimTree",
|
||||
text = "Explorer",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
{
|
||||
filetype = "DiffviewFiles",
|
||||
text = "Diff View",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
{
|
||||
filetype = "flutterToolsOutline",
|
||||
text = "Flutter Outline",
|
||||
highlight = "PanelHeading",
|
||||
},
|
||||
{
|
||||
filetype = "packer",
|
||||
text = "Packer",
|
||||
highlight = "PanelHeading",
|
||||
padding = 1,
|
||||
},
|
||||
},
|
||||
color_icons = true, -- whether or not to add the filetype icon highlights
|
||||
show_buffer_icons = true, -- disable filetype icons for buffers
|
||||
show_buffer_close_icons = false,
|
||||
show_close_icon = false,
|
||||
show_tab_indicators = true,
|
||||
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
|
||||
-- can also be a table containing 2 custom separators
|
||||
-- [focused and unfocused]. eg: { '|', '|' }
|
||||
separator_style = { '', '' },
|
||||
enforce_regular_tabs = false,
|
||||
always_show_bufferline = false,
|
||||
hover = {
|
||||
enabled = false, -- requires nvim 0.8+
|
||||
delay = 200,
|
||||
reveal = { "close" },
|
||||
},
|
||||
sort_by = "id",
|
||||
},
|
||||
}
|
||||
|
||||
bufferline.setup(config)
|
|
@ -1,103 +0,0 @@
|
|||
local cmp_status_ok, cmp = pcall(require, 'cmp')
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local luasnip_status_ok, luasnip = pcall(require, 'luasnip')
|
||||
if not luasnip_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local cmp_window = require "cmp.utils.window"
|
||||
|
||||
cmp_window.info_ = cmp_window.info
|
||||
cmp_window.info = function(self)
|
||||
local info = self:info_()
|
||||
info.scrollable = false
|
||||
return info
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = {
|
||||
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
||||
col_offset = -3,
|
||||
side_padding = 0,
|
||||
},
|
||||
},
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||
kind.kind = " " .. (strings[1] or "") .. " "
|
||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||
|
||||
return kind
|
||||
end,
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<C-j>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
|
||||
["<C-k>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
|
||||
["<CR>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||
}),
|
||||
["<C-e>"] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
confirm_opts = {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
}
|
||||
})
|
|
@ -1,11 +0,0 @@
|
|||
local status_ok, comment = pcall(require, "Comment")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
comment.setup({
|
||||
mappings = {
|
||||
basic = false,
|
||||
extra = false
|
||||
}
|
||||
})
|
|
@ -1,24 +0,0 @@
|
|||
local dap_status_ok, dap = pcall(require, 'dap')
|
||||
if not dap_status_ok then
|
||||
return
|
||||
end
|
||||
local dap_ui_status_ok, dapui = pcall(require, 'dapui')
|
||||
if not dap_ui_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local icons = require('config.icons').list
|
||||
|
||||
vim.fn.sign_define("DapBreakpoint", { text = icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "" })
|
||||
|
||||
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
|
|
@ -1,27 +0,0 @@
|
|||
local dap_ui_status_ok, dapui = pcall(require, 'nvim-dap-ui')
|
||||
if not dap_ui_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
dapui.setup {
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
'scopes',
|
||||
'breakpoints',
|
||||
'stacks',
|
||||
'watches',
|
||||
},
|
||||
size = 40,
|
||||
position = 'left',
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
'repl',
|
||||
'console',
|
||||
},
|
||||
size = 10,
|
||||
position = 'bottom',
|
||||
},
|
||||
},
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
local status_ok, gitsigns = pcall(require, "gitsigns")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
gitsigns.setup {
|
||||
signs = {
|
||||
add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
|
||||
change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
||||
delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
||||
topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
||||
changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
},
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = "single",
|
||||
style = "minimal",
|
||||
relative = "cursor",
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
local status_ok, illuminate = pcall(require, "illuminate")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
vim.g.Illuminate_ftblacklist = { 'alpha', 'NvimTree' }
|
||||
|
||||
illuminate.configure {
|
||||
providers = {
|
||||
"lsp",
|
||||
"treesitter",
|
||||
"regex",
|
||||
},
|
||||
delay = 200,
|
||||
filetypes_denylist = {
|
||||
"dirvish",
|
||||
"fugitive",
|
||||
"alpha",
|
||||
"NvimTree",
|
||||
"packer",
|
||||
"neogitstatus",
|
||||
"Trouble",
|
||||
"lir",
|
||||
"Outline",
|
||||
"spectre_panel",
|
||||
"toggleterm",
|
||||
"DressingSelect",
|
||||
"TelescopePrompt",
|
||||
},
|
||||
filetypes_allowlist = {},
|
||||
modes_denylist = {},
|
||||
modes_allowlist = {},
|
||||
providers_regex_syntax_denylist = {},
|
||||
providers_regex_syntax_allowlist = {},
|
||||
under_cursor = true,
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
local status_ok, indent_blankline = pcall(require, "indent_blankline")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
indent_blankline.setup {
|
||||
char = "▏",
|
||||
context_char = "▏",
|
||||
show_trailing_blankline_indent = false,
|
||||
show_first_indent_level = true,
|
||||
use_treesitter = true,
|
||||
show_current_context = false,
|
||||
show_end_of_line = false,
|
||||
buftype_exclude = { "terminal", "nofile" },
|
||||
filetype_exclude = {
|
||||
"help",
|
||||
"packer",
|
||||
"NvimTree",
|
||||
},
|
||||
}
|
|
@ -1,244 +0,0 @@
|
|||
local icons = require('config.icons').list
|
||||
local plugins = {
|
||||
{
|
||||
"wbthomason/packer.nvim",
|
||||
config = function()
|
||||
require('config.keymaps').map("packer")
|
||||
end
|
||||
},
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "lewis6991/impatient.nvim" },
|
||||
{
|
||||
"lervag/vimtex",
|
||||
setup = function()
|
||||
vim.g.vimtex_view_method = "zathura"
|
||||
vim.g.tex_flavor = "latex"
|
||||
vim.g.vimtex_quickfix_mode = 0
|
||||
vim.o.conceallevel = 1
|
||||
vim.g.tex_conceal = 'abdmg'
|
||||
end,
|
||||
config = function()
|
||||
require('config.keymaps').map("vimtex")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"kylechui/nvim-surround",
|
||||
config = function()
|
||||
require('plugins.nvim-surround')
|
||||
end
|
||||
},
|
||||
{
|
||||
"fladson/vim-kitty",
|
||||
ft = "kitty"
|
||||
},
|
||||
{ "kyazdani42/nvim-web-devicons" },
|
||||
{
|
||||
"felipec/vim-sanegx",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
},
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
config = function()
|
||||
require('plugins.whichkey')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/tokyonight.nvim",
|
||||
config = function()
|
||||
require('plugins.tokyonight')
|
||||
end
|
||||
},
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.todo-comments')
|
||||
end
|
||||
},
|
||||
{
|
||||
"akinsho/bufferline.nvim",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.bufferline')
|
||||
require('config.keymaps').map("bufferline")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.lualine')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"akinsho/toggleterm.nvim",
|
||||
config = function()
|
||||
require('plugins.toggleterm')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
after = "nvim-treesitter",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.indent-blankline')
|
||||
require('config.keymaps').map("blankline")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.illuminate')
|
||||
require('config.keymaps').map("illuminate")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
cmd = {
|
||||
"TSInstall",
|
||||
"TSBufEnable",
|
||||
"TSBufDisable",
|
||||
"TSEnable",
|
||||
"TSDisable",
|
||||
"TSModuleInfo"
|
||||
},
|
||||
run = ":TSUpdate",
|
||||
config = function()
|
||||
require('plugins.treesitter')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
ft = "gitcommit",
|
||||
setup = function()
|
||||
vim.api.nvim_create_autocmd({ "BufRead" }, {
|
||||
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
|
||||
callback = function()
|
||||
vim.fn.system("git rev-parse " .. vim.fn.expand "%:p:h")
|
||||
if vim.v.shell_error == 0 then
|
||||
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
|
||||
vim.schedule(function()
|
||||
require("packer").loader "gitsigns.nvim"
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
config = function()
|
||||
require('plugins.gitsigns')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
setup = function()
|
||||
require('config.keymaps').map("mason")
|
||||
end,
|
||||
config = function()
|
||||
require "plugins.mason"
|
||||
end,
|
||||
},
|
||||
{ "williamboman/mason-lspconfig.nvim" },
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
after = "mason-lspconfig.nvim",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.lspconfig')
|
||||
require('config.keymaps').map("lspconfig")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
config = function()
|
||||
require('plugins.null-ls')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
after = "nvim-dap",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.dapui')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.dap')
|
||||
require('config.keymaps').map("dap")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
config = function()
|
||||
require('plugins.cmp')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
after = "nvim-cmp",
|
||||
run = "make install_jsregexp",
|
||||
config = function()
|
||||
require('plugins.luasnip')
|
||||
end,
|
||||
},
|
||||
{ "saadparwaiz1/cmp_luasnip", after = "LuaSnip" },
|
||||
{ "hrsh7th/cmp-nvim-lua", after = "cmp_luasnip" },
|
||||
{ "hrsh7th/cmp-nvim-lsp", after = "cmp-nvim-lua" },
|
||||
{ "hrsh7th/cmp-buffer", after = "cmp-nvim-lsp" },
|
||||
{ "hrsh7th/cmp-path", after = "cmp-buffer" },
|
||||
{ "onsails/lspkind.nvim" },
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
after = "nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require('plugins.autopairs')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"goolord/alpha-nvim",
|
||||
config = function()
|
||||
require('plugins.alpha')
|
||||
end,
|
||||
},
|
||||
{
|
||||
"numToStr/Comment.nvim",
|
||||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.comment')
|
||||
require('config.keymaps').map("comment")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"lmburns/lf.nvim",
|
||||
commit = "383429497292dd8a84271e74a81c6db6993ca7ab",
|
||||
config = function()
|
||||
require('plugins.lf')
|
||||
require('config.keymaps').map("lf")
|
||||
end
|
||||
},
|
||||
}
|
||||
|
||||
local status_ok, packer = pcall(require, "packer")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
vim.cmd "packadd packer.nvim"
|
||||
packer.init {
|
||||
git = { clone_timeout = 6000 },
|
||||
display = {
|
||||
working_sym = icons.misc.Watch,
|
||||
error_sym = icons.ui.Close,
|
||||
done_sym = icons.ui.Check,
|
||||
removed_sym = icons.ui.MinusCircle,
|
||||
moved_sym = icons.ui.Forward,
|
||||
open_fn = function()
|
||||
return require('packer.util').float { border = "single" }
|
||||
end
|
||||
}
|
||||
}
|
||||
packer.startup { plugins }
|
|
@ -1,10 +0,0 @@
|
|||
local status_ok, lf = pcall(require, 'lf')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
lf.setup({
|
||||
mappings = false,
|
||||
winblend = 0,
|
||||
border = "rounded",
|
||||
})
|
|
@ -1,90 +0,0 @@
|
|||
local mason_lspconfig_status_ok, mason_lspconfig = pcall(require, 'mason-lspconfig')
|
||||
if not mason_lspconfig_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local lspconfig_status_ok, lspconfig = pcall(require, 'lspconfig')
|
||||
if not lspconfig_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem = {
|
||||
documentationFormat = { "markdown", "plaintext" },
|
||||
snippetSupport = true,
|
||||
preselectSupport = true,
|
||||
insertReplaceSupport = true,
|
||||
labelDetailsSupport = true,
|
||||
deprecatedSupport = true,
|
||||
commitCharactersSupport = true,
|
||||
tagSupport = { valueSet = { 1 } },
|
||||
resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local opts = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = {},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
mason_lspconfig.setup_handlers({
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup(opts)
|
||||
end,
|
||||
["intelephense"] = function()
|
||||
opts = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
storagePath = vim.fn.expand "$XDG_CACHE_HOME" .. "/intelephense",
|
||||
globalStoragePath = vim.fn.expand "$XDG_DATA_HOME" .. "/intelephense"
|
||||
},
|
||||
settings = {
|
||||
intelephense = {
|
||||
telemetry = {
|
||||
enable = false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lspconfig["intelephense"].setup(opts)
|
||||
end,
|
||||
["lua_ls"] = function()
|
||||
opts = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
|
||||
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true
|
||||
},
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
maxPreload = 100000,
|
||||
preloadFileSize = 10000,
|
||||
},
|
||||
},
|
||||
}
|
||||
lspconfig["lua_ls"].setup(opts)
|
||||
end
|
||||
})
|
|
@ -1,202 +0,0 @@
|
|||
local status_ok, lualine = pcall(require, 'lualine')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local colors = require('tokyonight.colors').setup({ transform = true })
|
||||
local icons = require('config.icons').list
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand('%:p:h')
|
||||
local gitdir = vim.fn.finddir('.git', filepath .. ';')
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
local config = {
|
||||
options = {
|
||||
component_separators = '',
|
||||
section_separators = '',
|
||||
-- theme = {
|
||||
-- normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
-- inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
-- },
|
||||
disabled_filetypes = {
|
||||
statusline = { 'alpha' }
|
||||
},
|
||||
ignore_focus = { 'toggleterm', 'NvimTree' },
|
||||
globalstatus = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
}
|
||||
}
|
||||
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
local function mode_color()
|
||||
local color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.magenta,
|
||||
[''] = colors.magenta,
|
||||
V = colors.magenta,
|
||||
c = colors.blue,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[''] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
['r?'] = colors.cyan,
|
||||
['!'] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = color[vim.fn.mode()] }
|
||||
end
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = function()
|
||||
return mode_color()
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
local msg = 'None Active'
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
if client.name ~= "null-ls" then
|
||||
return client.name
|
||||
end
|
||||
msg = client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = ' LSP:',
|
||||
color = { fg = colors.white },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
'diagnostics',
|
||||
sources = { 'nvim_diagnostic' },
|
||||
symbols = { error = icons.diagnostics.BoldError .. ' ', warn = icons.diagnostics.BoldWarning .. ' ',
|
||||
info = icons.diagnostics.BoldInformation },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
return '%='
|
||||
end,
|
||||
}
|
||||
|
||||
ins_left {
|
||||
'filename',
|
||||
color = { fg = colors.magenta, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
local current_line = vim.fn.line "."
|
||||
local total_lines = vim.fn.line "$"
|
||||
local chars = icons.progress
|
||||
local line_ratio = current_line / total_lines
|
||||
local index = math.ceil(line_ratio * #chars)
|
||||
return chars[index]
|
||||
end,
|
||||
color = { fg = colors.yellow }
|
||||
}
|
||||
|
||||
ins_left {
|
||||
'%04l:%04c',
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'o:encoding',
|
||||
fmt = string.upper,
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'fileformat',
|
||||
fmt = string.upper,
|
||||
icons_enabled = false,
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'branch',
|
||||
icon = icons.git.Branch,
|
||||
color = { fg = colors.violet, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'diff',
|
||||
symbols = { added = ' ', modified = '柳', removed = ' ' },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
}
|
||||
|
||||
ins_right {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = function()
|
||||
return mode_color()
|
||||
end,
|
||||
padding = { left = 1 },
|
||||
}
|
||||
|
||||
lualine.setup(config)
|
|
@ -1,48 +0,0 @@
|
|||
local status_ok, luasnip = pcall(require, "luasnip")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local f = luasnip.function_node
|
||||
|
||||
luasnip.setup({
|
||||
history = true,
|
||||
enable_autosnippets = true,
|
||||
update_events = { "TextChanged", "TextChangedI" },
|
||||
snip_env = {
|
||||
s = function(...)
|
||||
local snip = luasnip.s(...)
|
||||
table.insert(getfenv(2).ls_file_snippets, snip)
|
||||
end,
|
||||
parse = function(...)
|
||||
local snip = luasnip.parser.parse_snippet(...)
|
||||
table.insert(getfenv(2).ls_file_snippets, snip)
|
||||
end,
|
||||
reference = function(node)
|
||||
return f(function(args, _) return args[1][1] end, node)
|
||||
end,
|
||||
capture = function(index)
|
||||
return f(function(_, snip, user_arg1) return snip.captures[user_arg1] end, nil, { user_args = { index } })
|
||||
end
|
||||
},
|
||||
})
|
||||
|
||||
local _, lloader = pcall(require, "luasnip.loaders.from_lua")
|
||||
if status_ok then
|
||||
lloader.load({ paths = os.getenv("XDG_CONFIG_HOME") .. "/nvim/lua/snippets" })
|
||||
end
|
||||
|
||||
local _, vloader = pcall(require, "luasnip.loaders.from_vscode")
|
||||
if status_ok then
|
||||
vloader.lazy_load({ paths = os.getenv("XDG_CONFIG_HOME") .. "/nvim/lua/snippets" })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
callback = function()
|
||||
if luasnip.session.current_nodes[vim.api.nvim_get_current_buf()]
|
||||
and not luasnip.session.jump_active
|
||||
then
|
||||
luasnip.unlink_current()
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -1,19 +0,0 @@
|
|||
local status_ok, mason = pcall(require, 'mason')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local icons = require('config.icons').list
|
||||
|
||||
mason.setup({
|
||||
ui = {
|
||||
border = "none",
|
||||
icons = {
|
||||
package_installed = icons.ui.Check,
|
||||
package_pending = icons.ui.BoldArrowRight,
|
||||
package_uninstalled = icons.ui.BoldClose,
|
||||
},
|
||||
},
|
||||
log_level = vim.log.levels.INFO,
|
||||
max_concurrent_installers = 4,
|
||||
})
|
|
@ -1,22 +0,0 @@
|
|||
local null_ls_status_ok, null_ls = pcall(require, 'null-ls')
|
||||
if not null_ls_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
|
||||
local formatting = null_ls.builtins.formatting
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
|
||||
-- WARN: If this setup doesn't work it's probably because a different language server with a formatter is taking precedence
|
||||
-- https://github.com/LunarVim/LunarVim/blob/master/lua/lvim/lsp/utils.lua#L172
|
||||
|
||||
null_ls.setup({
|
||||
debug = false,
|
||||
sources = {
|
||||
formatting.black.with { extra_args = { "--fast" } },
|
||||
formatting.shfmt,
|
||||
-- formatting.stylua,
|
||||
-- diagnostics.flake8,
|
||||
},
|
||||
})
|
|
@ -1,19 +0,0 @@
|
|||
local status_ok, surround = pcall(require, 'nvim-surround')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
surround.setup({
|
||||
-- keymaps = {
|
||||
-- insert = "<C-g>s",
|
||||
-- insert_line = "<C-g>S",
|
||||
-- normal = "ys",
|
||||
-- normal_cur = "yss",
|
||||
-- normal_line = "yS",
|
||||
-- normal_cur_line = "ySS",
|
||||
-- visual = "S",
|
||||
-- visual_line = "gS",
|
||||
-- delete = "ds",
|
||||
-- change = "cs",
|
||||
-- },
|
||||
})
|
|
@ -1,11 +0,0 @@
|
|||
local status_ok, todo_comments = pcall(require, 'todo-comments')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
todo_comments.setup({
|
||||
highlight = {
|
||||
multiline = false,
|
||||
comments_only = false
|
||||
}
|
||||
})
|
|
@ -1,33 +0,0 @@
|
|||
local status_ok, toggleterm = pcall(require, 'toggleterm')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
toggleterm.setup({
|
||||
size = 20,
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true,
|
||||
shade_terminals = true,
|
||||
shading_factor = 2,
|
||||
start_in_insert = true,
|
||||
insert_mappings = true,
|
||||
persist_size = true,
|
||||
direction = "float",
|
||||
close_on_exit = true,
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
border = "rounded",
|
||||
},
|
||||
})
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local lazygit = Terminal:new({ cmd = "lazygit", hidden = true })
|
||||
|
||||
function _LAZYGIT_TOGGLE()
|
||||
lazygit:toggle()
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
local status_ok, tokyonight = pcall(require, 'tokyonight')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
tokyonight.setup({
|
||||
style = "night",
|
||||
transparent = true,
|
||||
terminal_colors = true,
|
||||
dim_inactive = true,
|
||||
})
|
||||
vim.cmd [[colorscheme tokyonight]]
|
|
@ -1,16 +0,0 @@
|
|||
local status_ok, configs = pcall(require, 'nvim-treesitter.configs')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
configs.setup({
|
||||
ensure_installed = { "lua", "bash", "c" },
|
||||
auto_install = true,
|
||||
autopairs = {
|
||||
enable = false,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
enable_autocmd = false,
|
||||
},
|
||||
})
|
|
@ -1,54 +0,0 @@
|
|||
local status_ok, whichkey = pcall(require, 'which-key')
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local icons = require('config.icons').list
|
||||
|
||||
whichkey.setup({
|
||||
plugins = {
|
||||
marks = false,
|
||||
registers = false,
|
||||
presets = {
|
||||
operators = false,
|
||||
motions = false,
|
||||
text_objects = false,
|
||||
windows = false,
|
||||
nav = false,
|
||||
z = false,
|
||||
g = false,
|
||||
}
|
||||
},
|
||||
spelling = {
|
||||
enabled = false,
|
||||
suggestions = 20,
|
||||
},
|
||||
icons = {
|
||||
breadcrumb = icons.ui.DoubleChevronRight,
|
||||
separator = icons.ui.BoldArrowRight,
|
||||
group = icons.ui.Plus,
|
||||
},
|
||||
popup_mappings = {
|
||||
scroll_down = "<c-d>",
|
||||
scroll_up = "<c-u>",
|
||||
},
|
||||
window = {
|
||||
border = "single",
|
||||
position = "bottom",
|
||||
margin = { 1, 0, 1, 0 },
|
||||
padding = { 2, 2, 2, 2 },
|
||||
winblend = 0,
|
||||
},
|
||||
layout = {
|
||||
height = { min = 4, max = 25 },
|
||||
width = { min = 20, max = 50 },
|
||||
spacing = 3,
|
||||
align = "left",
|
||||
},
|
||||
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " },
|
||||
triggers = "auto",
|
||||
triggers_blacklist = {
|
||||
i = { "j", "k" },
|
||||
v = { "j", "k", "y" },
|
||||
},
|
||||
})
|
|
@ -1,330 +0,0 @@
|
|||
return {
|
||||
s({ trig = "sst", name = "Standard Template" }, fmt([[
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {{
|
||||
{}
|
||||
return EXIT_SUCCESS;
|
||||
}}
|
||||
]], { i(0) })),
|
||||
s({ trig = "sstp", name = "Preprocessor Template" }, fmt([[
|
||||
// #define NDEBUG // disables assert()
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
]], {})),
|
||||
s({ trig = "main", name = "main(int argc, char *argv[])" }, fmt([[
|
||||
int main(int argc, char *argv[]) {{
|
||||
{}
|
||||
return EXIT_SUCCESS;
|
||||
}}
|
||||
]], { i(0) })),
|
||||
s({ trig = "mainn", name = "main(void)" }, fmt([[
|
||||
int main(void) {{
|
||||
{}
|
||||
return EXIT_SUCCESS;
|
||||
}}
|
||||
]], { i(0) })),
|
||||
s({ trig = "#inc", name = "#include <...>" }, fmt([[
|
||||
#include <{}>
|
||||
]], { i(1) })),
|
||||
s({ trig = "#inc", name = "#include \"...\"" }, fmt([[
|
||||
#include "{}"
|
||||
]], { i(1) })),
|
||||
s({ trig = "#def", name = "#define macro" }, fmt([[
|
||||
#define {}
|
||||
]], { i(0) })),
|
||||
s({ trig = "#deff", name = "#define macro()" }, fmt([[
|
||||
#define {}({}) ({})
|
||||
]], { i(1), i(2), i(3) })),
|
||||
s({ trig = "#if", name = "#if" }, fmt([[
|
||||
#if {}
|
||||
{}
|
||||
#endif /* if {} */
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "#ifdef", name = "#ifdef" }, fmt([[
|
||||
#ifdef {}
|
||||
{}
|
||||
#endif /* ifdef {} */
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "#ifndef", name = "#ifndef" }, fmt([[
|
||||
#ifndef {}
|
||||
{}
|
||||
#endif /* ifndef {} */
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "once", name = "Header Include Guard" }, fmt([[
|
||||
#ifndef {}_H
|
||||
#define {}_H
|
||||
{}
|
||||
#endif /* end of include guard: {} */
|
||||
]], { i(1), reference(1), i(0), reference(1) })),
|
||||
s({ trig = "nocpp", name = "extern C", dscr = "Disable C++ name mangling in C headers" }, fmt([[
|
||||
#ifdef __cplusplus
|
||||
extern "C" {{
|
||||
#endif
|
||||
{}
|
||||
#ifdef __cplusplus
|
||||
}} /* extern "C" */
|
||||
#endif
|
||||
]], { i(0) })),
|
||||
s({ trig = "#err", name = "#error" }, fmt([[
|
||||
#error "{}"
|
||||
]], { i(1) })),
|
||||
s({ trig = "#warn", name = "#warning" }, fmt([[
|
||||
#warning "{}"
|
||||
]], { i(1) })),
|
||||
s({ trig = "if", name = "if" }, fmt([[
|
||||
if ({}) {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "ife", name = "if else" }, fmt([[
|
||||
if ({}) {{
|
||||
{}
|
||||
}} else {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(2), i(0) })),
|
||||
s({ trig = "el", name = "else" }, fmt([[
|
||||
else {{
|
||||
{}
|
||||
}}
|
||||
]], { i(0) })),
|
||||
s({ trig = "elif", name = "else if" }, fmt([[
|
||||
else if ({}) {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "t", name = "Ternary" }, fmt([[
|
||||
{} ? {} : {}
|
||||
]], { i(1), i(2), i(0) })),
|
||||
s({ trig = "switch", name = "Switch" }, fmt([[
|
||||
switch ({}) {{
|
||||
{}
|
||||
default:
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(0), i(2) })),
|
||||
s({ trig = "switchn", name = "Switch Without Default" }, fmt([[
|
||||
switch ({}) {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "case", name = "Case" }, fmt([[
|
||||
case {}:
|
||||
{}
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "while", name = "While" }, fmt([[
|
||||
while ({}) {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "do", name = "Do While" }, fmt([[
|
||||
do {{
|
||||
{}
|
||||
}} while({});
|
||||
]], { i(0), i(1) })),
|
||||
s({ trig = "for", name = "For" }, fmt([[
|
||||
for ({}) {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "ret", name = "return" }, fmt([[
|
||||
return {};
|
||||
]], { i(1) })),
|
||||
s({ trig = "ex", name = "exit()" }, fmt([[
|
||||
exit({});
|
||||
]], { i(1) })),
|
||||
s({ trig = "fund", name = "Function Declaration" }, fmt([[
|
||||
{}({});
|
||||
]], { i(1), i(2) })),
|
||||
s({ trig = "fun", name = "Function Definition" }, fmt([[
|
||||
{}({}) {{
|
||||
{}
|
||||
}}
|
||||
]], { i(1), i(2), i(0) })),
|
||||
s({ trig = "td", name = "typedef" }, fmt([[
|
||||
typedef {};
|
||||
]], { i(1) })),
|
||||
s({ trig = "tdst", name = "typedef struct" }, fmt([[
|
||||
typedef struct {} {};
|
||||
]], { reference(1), i(1) })),
|
||||
s({ trig = "tduo", name = "typedef union" }, fmt([[
|
||||
typedef union {} {};
|
||||
]], { reference(1), i(1) })),
|
||||
s({ trig = "tden", name = "typedef enum" }, fmt([[
|
||||
typedef enum {} {};
|
||||
]], { reference(1), i(1) })),
|
||||
s({ trig = "st", name = "Struct" }, fmt([[
|
||||
struct {} {{
|
||||
{}
|
||||
}};
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "stt", name = "Struct Type" }, fmt([[
|
||||
typedef struct {} {{
|
||||
{}
|
||||
}} {};
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "uo", name = "Union" }, fmt([[
|
||||
union {} {{
|
||||
{}
|
||||
}};
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "uot", name = "Union Type" }, fmt([[
|
||||
typedef union {} {{
|
||||
{}
|
||||
}} {};
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "enum", name = "Enum" }, fmt([[
|
||||
enum {} {{
|
||||
{}
|
||||
}};
|
||||
]], { i(1), i(0) })),
|
||||
s({ trig = "enumt", name = "Enum Type" }, fmt([[
|
||||
typedef enum {} {{
|
||||
{}
|
||||
}} {};
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "pri", name = "printf()" }, fmt([[
|
||||
printf("{}\n", {});
|
||||
]], { i(1, "%s"), i(2) })),
|
||||
s({ trig = "fpri", name = "fprintf()" }, fmt([[
|
||||
fprintf({}, "{}\n", {});
|
||||
]], { i(1, "stderr"), i(2, "%s"), i(3) })),
|
||||
s({ trig = "spri", name = "sprintf()" }, fmt([[
|
||||
sprintf({}, "{}\n", {});
|
||||
]], { i(1, "buf"), i(2, "%s"), i(3) })),
|
||||
s({ trig = "snpri", name = "snprintf()" }, fmt([[
|
||||
snprintf({}, {}, "{}\n", {});
|
||||
]], { i(1, "buf"), i(2, "max"), i(3, "%s"), i(4) })),
|
||||
s({ trig = "sca", name = "scanf()" }, fmt([[
|
||||
scanf("{}", {});
|
||||
]], { i(1, "%i"), i(2) })),
|
||||
s({ trig = "fsca", name = "fscanf()" }, fmt([[
|
||||
fscanf({}, "{}", {});
|
||||
]], { i(1, "stdin"), i(2, "%i"), i(3) })),
|
||||
s({ trig = "ssca", name = "sscanf()" }, fmt([[
|
||||
sscanf({}, "{}", {});
|
||||
]], { i(1, "buf"), i(2, "%i"), i(3) })),
|
||||
s({ trig = "priv", name = "Print Variable" }, fmt([[
|
||||
printf("{} = {}\n", {});
|
||||
]], { reference(2), i(1, "%i"), i(2) })),
|
||||
s({ trig = "warn", name = "warn()" }, fmt([[
|
||||
warn("{}"{});
|
||||
]], { i(1, "%s"), i(2) })),
|
||||
s({ trig = "warnx", name = "warnx()" }, fmt([[
|
||||
warnx("{}"{});
|
||||
]], { i(1, "%s"), i(2) })),
|
||||
s({ trig = "err", name = "err()" }, fmt([[
|
||||
err("{}"{});
|
||||
]], { i(1, "%s"), i(2) })),
|
||||
s({ trig = "errx", name = "errx()" }, fmt([[
|
||||
errx("{}"{});
|
||||
]], { i(1, "%s"), i(2) })),
|
||||
s({ trig = "asr", name = "assert()" }, fmt([[
|
||||
assert({});
|
||||
]], { i(1) })),
|
||||
s({ trig = "stasr", name = "static_assert()" }, fmt([[
|
||||
static_assert({}, "{}");
|
||||
]], { i(1), i(2, "Fuck!") })),
|
||||
s({ trig = "Stasr", name = "static_assert() 1 Parameter" }, fmt([[
|
||||
static_assert({});
|
||||
]], { i(1) })),
|
||||
s({ trig = "mlc", name = "malloc()" }, fmt([[
|
||||
{} = malloc(sizeof({}[{}]){});
|
||||
]], { i(1, "ptr"), i(2, "int"), i(3), i(4) })),
|
||||
s({ trig = "clc", name = "calloc()" }, fmt([[
|
||||
{} = calloc({}, sizeof({}){});
|
||||
]], { i(1, "ptr"), i(2), i(3, "int"), i(4) })),
|
||||
s({ trig = "rlc", name = "realloc()" }, fmt([[
|
||||
{} = realloc({}, sizeof({}[{}]){});
|
||||
]], { i(1, "ptr"), i(2), i(3, "int"), i(4), i(5) })),
|
||||
s({ trig = "fre", name = "free()" }, fmt([[
|
||||
free({});
|
||||
]], { i(1, "ptr") })),
|
||||
s({ trig = "mlcd", name = "Malloc Declaration" }, fmt([[
|
||||
{} *{} = malloc(sizeof({}[{}]){});
|
||||
]], { i(1, "int"), i(2, "ptr"), reference(1), i(3), i(4) })),
|
||||
s({ trig = "clcd", name = "Calloc Declaration" }, fmt([[
|
||||
{} *{} = calloc({}, sizeof({}){});
|
||||
]], { i(1, "int"), i(2, "ptr"), i(3), reference(1), i(4) })),
|
||||
s({ trig = "mlct", name = "Malloc Template" }, fmt([[
|
||||
{} *{} = malloc(sizeof({}[{}]));
|
||||
if (!{}) {{
|
||||
printf(stderr, "{}\n"{});
|
||||
{}
|
||||
}}
|
||||
{}
|
||||
free({});
|
||||
]], { i(1, "int"), i(2, "ptr"), reference(1), i(3), reference(2), i(4, "Failed to malloc!"), i(5),
|
||||
i(6, "exit(EXIT_FAILURE);"), i(0), reference(2) })),
|
||||
s({ trig = "clct", name = "Calloc Template" }, fmt([[
|
||||
{} *{} = calloc({}, sizeof({}));
|
||||
if (!{}) {{
|
||||
printf(stderr, "{}\n"{});
|
||||
{}
|
||||
}}
|
||||
{}
|
||||
free({});
|
||||
]], { i(1, "int"), i(2, "ptr"), i(3), reference(1), reference(2), i(4, "Failed to calloc!"), i(5),
|
||||
i(6, "exit(EXIT_FAILURE);"), i(0), reference(2) })),
|
||||
s({ trig = "/", name = "Comment" }, fmt([[
|
||||
/* {} */
|
||||
]], { i(1) })),
|
||||
s({ trig = "//", name = "Multiline Comment" }, fmt([[
|
||||
/*
|
||||
* {}
|
||||
*/
|
||||
]], { i(1) })),
|
||||
s({ trig = "///", name = "Multiline Double-Star Comment" }, fmt([[
|
||||
/**
|
||||
** {}
|
||||
**/
|
||||
]], { i(1) })),
|
||||
s({ trig = "dox", name = "Doxygen Template" }, fmt([[
|
||||
/*! {}
|
||||
* @brief {}
|
||||
*
|
||||
* {}
|
||||
*/
|
||||
]], { i(1), i(2, "This is something undocumented."), i(3, "Nothing to say here...") })),
|
||||
s({ trig = "dfun", name = "Doxygen Function" }, fmt([[
|
||||
/*!
|
||||
* @brief {}
|
||||
*
|
||||
* {}
|
||||
*
|
||||
* @return {}
|
||||
*/
|
||||
{}({});
|
||||
]], { i(3, "This function is undocumented."), i(4, "Nothing to say here..."), i(5, "Nothing."), i(1), i(2) })),
|
||||
s({ trig = "todo", name = "Doxygen Todo" }, fmt([[
|
||||
/*! TODO: {}
|
||||
*
|
||||
* @todo {}
|
||||
*/
|
||||
]], { i(1), i(2) })),
|
||||
s({ trig = "dgr", name = "Doxygen Group" }, fmt([[
|
||||
/*! @name {}
|
||||
* {}
|
||||
* @{{
|
||||
*/
|
||||
{}
|
||||
/*! @}}
|
||||
*/
|
||||
]], { i(1, "Undocumented Group"), i(2, "This group is undocumented."), i(0) })),
|
||||
s({ trig = "alen", name = "Array Length" }, fmt([[
|
||||
(sizeof {} / sizeof {}[0])
|
||||
]], { i(1), reference(1) })),
|
||||
s({ trig = "lls", name = "Linked List" }, fmt([[
|
||||
struct {} {{
|
||||
{}
|
||||
{} *{};
|
||||
}} {};
|
||||
]], { i(1, "Node"), i(0), reference(1), i(2, "Next"), reference(1) })),
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
-- Copied from Gilles Castel (R.I.P.)
|
||||
-- https://castel.dev/post/lecture-notes-1/
|
||||
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
|
||||
local function has_value(tab, val)
|
||||
for _, value in ipairs(tab) do
|
||||
if value == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function cond_space(args, _)
|
||||
print(args[1][1]:sub(1, 1))
|
||||
if (args[1][1] and has_value({ ',', '.', '?', '-', ' ' }, args[1][1]:sub(1, 1))) then
|
||||
return ''
|
||||
end
|
||||
return ' '
|
||||
end
|
||||
|
||||
local function sub_capture(index, first, last)
|
||||
return f(function(_, snip, user_arg1) return snip.captures[user_arg1]:sub(first, last) end, nil,
|
||||
{ user_args = { index } })
|
||||
end
|
||||
|
||||
local function in_comment()
|
||||
return vim.fn['vimtex#syntax#in_comment']() == 1
|
||||
end
|
||||
|
||||
local function in_math()
|
||||
return vim.fn['vimtex#syntax#in_mathzone']() == 1
|
||||
end
|
||||
|
||||
local function in_env(name)
|
||||
local x, y = vim.fn['vimtex#env#is_inside'](name)
|
||||
return (x ~= '0' and y ~= '0')
|
||||
end
|
||||
|
||||
return {
|
||||
}, {
|
||||
s({ trig = "^beg", regTrig = true, wordTrig = false, name = "begin{} / end{}" }, fmt([[
|
||||
\begin{{{}}}
|
||||
{}
|
||||
\end{{{}}}
|
||||
]], { i(1), i(0), reference(1) })),
|
||||
s({ trig = "mk", name = "Inline Math" }, fmt([[
|
||||
${}${}{}
|
||||
]], { i(1), f(cond_space, 2), i(2) })),
|
||||
s({ trig = "dm", name = "Display Math" }, fmt([[
|
||||
\[
|
||||
{}
|
||||
.\]
|
||||
]], { i(1) })),
|
||||
s({ trig = "([A-Za-z])(%d)", regTrig = true, name = "Subscript" }, fmt([[
|
||||
{}_{}
|
||||
]], { capture(1), capture(2) })),
|
||||
s({ trig = "([A-Za-z])_(%d)", regTrig = true, name = "Subscript" }, fmt([[
|
||||
{}_{{{}}}
|
||||
]], { capture(1), capture(2) })),
|
||||
s({ trig = " td", wordTrig = false, name = "Superscript" }, fmt([[
|
||||
^{{{}}}
|
||||
]], { i(1) })),
|
||||
s({ trig = " sr", wordTrig = false, name = "Square" }, fmt([[
|
||||
^2
|
||||
]], {})),
|
||||
s({ trig = " cb", wordTrig = false, name = "Cube" }, fmt([[
|
||||
^3
|
||||
]], {})),
|
||||
s({ trig = " cl", wordTrig = false, name = "Complement" }, fmt([[
|
||||
^{{c}}
|
||||
]], {})),
|
||||
s({ trig = "//", wordTrig = false, name = "Fraction" }, fmt([[
|
||||
\\frac{{{}}}{{{}}}
|
||||
]], { i(1), i(2) })),
|
||||
-- if lua patterns had conditionals this would be less of a mess
|
||||
-- unfortunately this also expands on incomplete ^{} superscripts e.g. 4\pi^2}/
|
||||
ms({
|
||||
{ trig = "(%d+)/" },
|
||||
{ trig = "(%d*\\?[A-Za-z]+[%^_]{?%d+}?)/", priority = 1001 },
|
||||
common = { regTrig = true, name = "Fraction" }
|
||||
}, fmt([[
|
||||
\\frac{{{}}}{{{}}}
|
||||
]], { capture(1), i(1) })),
|
||||
s({ trig = "(%b())/", name = "Fraction", regTrig = true }, fmt([[
|
||||
\\frac{{{}}}{{{}}}
|
||||
]], { sub_capture(1, 2, -2), i(1) })),
|
||||
s({ trig = "([A-Za-z])bar", regTrig = true, name = "Overline" }, fmt([[
|
||||
\overline{{{}}}
|
||||
]], { capture(1) })),
|
||||
s({ trig = "bar", name = "Overline" }, fmt([[
|
||||
\overline{{{}}}
|
||||
]], { i(1) })),
|
||||
s({ trig = "([A-Za-z])hat", regTrig = true, name = "Hat" }, fmt([[
|
||||
\hat{{{}}}
|
||||
]], { capture(1) })),
|
||||
s({ trig = "hat", name = "Hat" }, fmt([[
|
||||
\hat{{{}}}
|
||||
]], { i(1) })),
|
||||
-- TODO: continue porting these snippets: https://castel.dev/post/lecture-notes-1/#fractions
|
||||
}
|
21
.gitmodules
vendored
21
.gitmodules
vendored
|
@ -1,21 +0,0 @@
|
|||
[submodule ".local/share/zsh/plugins/fast-syntax-highlighlighting"]
|
||||
path = .local/share/zsh/plugins/fast-syntax-highlighlighting
|
||||
url = https://github.com/zdharma-continuum/fast-syntax-highlighting
|
||||
[submodule ".local/src/dwm"]
|
||||
path = .local/src/dwm
|
||||
url = https://git.snaile.de/luca/dwm
|
||||
[submodule ".local/src/dmenu"]
|
||||
path = .local/src/dmenu
|
||||
url = https://git.snaile.de/luca/dmenu
|
||||
[submodule ".local/src/dwmblocks"]
|
||||
path = .local/src/dwmblocks
|
||||
url = https://git.snaile.de/luca/dwmblocks
|
||||
[submodule ".local/share/icons/tokyonight-icons"]
|
||||
path = .local/share/icons/tokyonight-icons
|
||||
url = https://git.snaile.de/luca/tokyonight-icons
|
||||
[submodule ".local/share/themes/tokyonight-theme"]
|
||||
path = .local/share/themes/tokyonight-theme
|
||||
url = https://git.snaile.de/luca/tokyonight-theme
|
||||
[submodule ".local/share/icons/tokyonight-theme"]
|
||||
path = .local/share/icons/tokyonight-theme
|
||||
url = https://git.snaile.de/luca/tokyonight-theme
|
|
@ -13,7 +13,7 @@ fi
|
|||
if ls /sys/class/net/e*/operstate 1>/dev/null 2>&1; then
|
||||
for e in /sys/class/net/e*/operstate; do
|
||||
if_icon="$(sed "s/down//;s/up//" $e)"
|
||||
printf "$shift\033[11m%s\033[10m" "$if_icon"
|
||||
printf "$shift\033[10m%s\033[10m" "$if_icon"
|
||||
shift=" "
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
if command -v pacman 1>/dev/null 2>&1; then
|
||||
echo -n "$(pacman -Qu | grep -Fcv "[ignored]" | sed "s/^//;s/^ 0$//g")"
|
||||
echo -n "$(pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/ /;s/^ 0$//g")"
|
||||
fi
|
||||
|
||||
if command -v apt 1>/dev/null 2>&1; then
|
||||
|
@ -11,5 +11,5 @@ if command -v apt 1>/dev/null 2>&1; then
|
|||
print="$print$i/"
|
||||
done
|
||||
|
||||
[ -n "$icon" ] && printf "$icon" && echo " $print" | sed 's/\/$//'
|
||||
[ -n "$icon" ] && printf "$icon " && echo " $print" | sed 's/\/$//'
|
||||
fi
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit c522c6a5dd1cb8d53c8bfc47745f313a734eea61
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 67c4bb6d6bb415acea9d1c9a97152083d7f9c724
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 7c390ee3bfa8069b8519582399e0a67444e6ea61
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 6fbc9dbb001ef05969121c9f45a6a1734be0e5bc
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 166f942f788b9b50676ca5e5869f4b9621e45d8f
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 44e024ba6d8d2197a2d1a56937e9931c8a046c55
|
Loading…
Add table
Reference in a new issue