style(nvim): format with stylua

This commit is contained in:
Price Hiller 2023-09-13 16:32:27 -05:00
parent ec4f0146ad
commit b8765d1df6
No known key found for this signature in database
18 changed files with 160 additions and 153 deletions

View File

@ -23,7 +23,7 @@ vim.keymap.set("n", "<leader>fr", function()
"-o",
executable_path,
"&& \n",
executable_path
executable_path,
}
require("toggleterm").exec(table.concat(cmd, " "))
end, {

View File

@ -10,12 +10,12 @@ vim.keymap.set("n", "<leader>fr", function()
"nix-instantiate",
"--eval",
"--strict",
vim.api.nvim_buf_get_name(0)
vim.api.nvim_buf_get_name(0),
}
require("toggleterm").exec(table.concat(cmd, " "))
end, {
buffer = true,
desc = "Nix: Run with default output"
desc = "Nix: Run with default output",
})
vim.keymap.set("n", "<leader>fj", function()
@ -26,10 +26,10 @@ vim.keymap.set("n", "<leader>fj", function()
"--json",
vim.api.nvim_buf_get_name(0),
"|",
"jq"
"jq",
}
require("toggleterm").exec(table.concat(cmd, " "))
end, {
buffer = true,
desc = "Nix: Run with json output"
desc = "Nix: Run with json output",
})

View File

@ -7,14 +7,22 @@ vim.api.nvim_create_autocmd("InsertCharPre", {
--- @return nil
callback = function(opts)
-- Only run if f-string escape character is typed
if vim.v.char ~= "{" then return end
if vim.v.char ~= "{" then
return
end
-- Get node and return early if not in a string
local node = vim.treesitter.get_node()
if not node then return end
if node:type() ~= "string" then node = node:parent() end
if not node or node:type() ~= "string" then return end
if not node then
return
end
if node:type() ~= "string" then
node = node:parent()
end
if not node or node:type() ~= "string" then
return
end
vim.print(node:type())
local row, col, _, _ = vim.treesitter.get_node_range(node)
@ -23,7 +31,9 @@ vim.api.nvim_create_autocmd("InsertCharPre", {
local first_char = vim.api.nvim_buf_get_text(opts.buf, row, col, row, col + 1, {})[1]
vim.print("row " .. row .. " col " .. col)
vim.print("char: '" .. first_char .. "'")
if first_char == "f" then return end
if first_char == "f" then
return
end
-- Otherwise, make the string a format string
vim.api.nvim_input("<Esc>m'" .. row + 1 .. "gg" .. col + 1 .. "|if<Esc>`'la")

View File

@ -17,18 +17,13 @@ M.setup = function()
if not strip_trail_space then
intercept_state = "`Disabled`"
end
vim.notify("Strip Trail Space set to " .. intercept_state, vim.log.levels.INFO,
{
title = "Strip Trail Space",
---@param win integer The window handle
on_open = function(win)
vim.api.nvim_buf_set_option(
vim.api.nvim_win_get_buf(win),
"filetype",
"markdown"
)
end
})
vim.notify("Strip Trail Space set to " .. intercept_state, vim.log.levels.INFO, {
title = "Strip Trail Space",
---@param win integer The window handle
on_open = function(win)
vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), "filetype", "markdown")
end,
})
end, { desc = "Toggles intercepting BufWritePre to strip trail space" })
-- NOTE: Remove trailing whitespace on save
@ -38,7 +33,7 @@ M.setup = function()
if strip_trail_space then
vim.cmd.StripTrailSpace()
end
end
end,
})
-- NOTE: Disables status column elements in Terminal buffer
@ -60,7 +55,9 @@ M.setup = function()
desc = "Delete [No Name] buffers",
callback = function(event)
if event.file == "" and vim.bo[event.buf].buftype == "" and not vim.bo[event.buf].modified then
vim.schedule(function() pcall(vim.api.nvim_buf_delete, event.buf, {}) end)
vim.schedule(function()
pcall(vim.api.nvim_buf_delete, event.buf, {})
end)
end
end,
})
@ -72,18 +69,13 @@ M.setup = function()
if not intercept_file_open then
intercept_state = "`Disabled`"
end
vim.notify("Intercept file open set to " .. intercept_state, vim.log.levels.INFO,
{
title = "Intercept File Open",
---@param win integer The window handle
on_open = function(win)
vim.api.nvim_buf_set_option(
vim.api.nvim_win_get_buf(win),
"filetype",
"markdown"
)
end
})
vim.notify("Intercept file open set to " .. intercept_state, vim.log.levels.INFO, {
title = "Intercept File Open",
---@param win integer The window handle
on_open = function(win)
vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), "filetype", "markdown")
end,
})
end, { desc = "Toggles intercepting BufNew to open files in custom programs" })
-- NOTE: Add "BufReadPre" to the autocmd events to also intercept files given on the command line, e.g.
@ -106,21 +98,13 @@ M.setup = function()
---@param fpath string The file path given to the program
---@param fname string The file name used in notifications
local function open_mime(buf, fpath, fname)
vim.notify(
string.format("Opening `%s` in external program", fname),
vim.log.levels.INFO,
{
title = "Open File in External Program",
---@param win integer The window handle
on_open = function(win)
vim.api.nvim_buf_set_option(
vim.api.nvim_win_get_buf(win),
"filetype",
"markdown"
)
end
}
)
vim.notify(string.format("Opening `%s` in external program", fname), vim.log.levels.INFO, {
title = "Open File in External Program",
---@param win integer The window handle
on_open = function(win)
vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), "filetype", "markdown")
end,
})
vim.system({ "xdg-open", fpath }, { detach = true })
vim.api.nvim_buf_delete(buf, { force = true })
end
@ -136,7 +120,7 @@ M.setup = function()
["mp4"] = function(buf, fpath, fname)
open_mime(buf, fpath, fname)
end,
["gif"] = "mp4"
["gif"] = "mp4",
}
---Get the extension callback for a given extension. Will do a recursive lookup if an extension callback is actually
@ -157,7 +141,7 @@ M.setup = function()
callback(bufnr, path, filename)
end
end
end
end,
})
end

View File

@ -5,7 +5,7 @@ local M = {}
---Traverse to indent >= or > current indent
---@param direction integer 1 - forwards | -1 - backwards
---@param equal boolean include lines equal to current indent in search?
local function indent_traverse(direction, equal) -- {{{
local function indent_traverse(direction, equal) -- {{{
return function()
-- Get the current cursor position
local current_line, column = unpack(vim.api.nvim_win_get_cursor(0))
@ -17,14 +17,11 @@ local function indent_traverse(direction, equal) -- {{{
-- Look for a line of appropriate indent
-- level without going out of the buffer
while (not match)
and (match_line ~= buf_length)
and (match_line ~= 1)
do
while (not match) and (match_line ~= buf_length) and (match_line ~= 1) do
match_line = match_line + direction
local match_line_str = vim.api.nvim_buf_get_lines(0, match_line - 1, match_line, false)[1]
-- local match_line_is_whitespace = match_line_str and match_line_str:match('^%s*$')
local match_line_is_whitespace = match_line_str:match('^%s*$')
local match_line_is_whitespace = match_line_str:match("^%s*$")
if equal then
match_indent = vim.fn.indent(match_line) <= vim.fn.indent(current_line)
@ -112,8 +109,8 @@ M.setup = function()
-- Binding to keep S-Space in terminals from not sending <Space>
vim.keymap.set("t", "<S-Space>", "<Space>", { silent = true, desc = "Terminal: Hack S-Space to Space" })
vim.keymap.set("n", "<C-j>", indent_traverse(1, true), { silent = true, desc = "Move: To next equal indent"})
vim.keymap.set("n", "<C-k>", indent_traverse(-1, true), { silent = true, desc = "Move: To previous equal indent"})
vim.keymap.set("n", "<C-j>", indent_traverse(1, true), { silent = true, desc = "Move: To next equal indent" })
vim.keymap.set("n", "<C-k>", indent_traverse(-1, true), { silent = true, desc = "Move: To previous equal indent" })
end
return M

View File

@ -66,25 +66,35 @@ return {
s = s / 100
l = l / 100
local r, g, b;
local r, g, b
if s == 0 then
r, g, b = l, l, l; -- achromatic
r, g, b = l, l, l -- achromatic
else
local function hue2rgb(p, q, t)
if t < 0 then t = t + 1 end
if t > 1 then t = t - 1 end
if t < 1 / 6 then return p + (q - p) * 6 * t end
if t < 1 / 2 then return q end
if t < 2 / 3 then return p + (q - p) * (2 / 3 - t) * 6 end
return p;
if t < 0 then
t = t + 1
end
if t > 1 then
t = t - 1
end
if t < 1 / 6 then
return p + (q - p) * 6 * t
end
if t < 1 / 2 then
return q
end
if t < 2 / 3 then
return p + (q - p) * (2 / 3 - t) * 6
end
return p
end
local q = l < 0.5 and l * (1 + s) or l + s - l * s;
local p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
local q = l < 0.5 and l * (1 + s) or l + s - l * s
local p = 2 * l - q
r = hue2rgb(p, q, h + 1 / 3)
g = hue2rgb(p, q, h)
b = hue2rgb(p, q, h - 1 / 3)
end
local function round(num)
@ -93,7 +103,6 @@ return {
return round(r * 255), round(g * 255), round(b * 255)
end
---@param sources table?
local standard_sources = function(sources)
sources = sources or {}
@ -170,8 +179,12 @@ return {
return conversion
end
end
return string.format("#%s%s%s", convertNumHex(red), convertNumHex(green),
convertNumHex(blue))
return string.format(
"#%s%s%s",
convertNumHex(red),
convertNumHex(green),
convertNumHex(blue)
)
end
if type(hl) == string then
@ -180,11 +193,11 @@ return {
hl = rgbToHex(red, green, blue)
end
local start, _, hue, saturation, lightness = hl:find(
"hsl.*%((%d+), (%d+)%%, (%d+)%%.*%)")
local start, _, hue, saturation, lightness =
hl:find("hsl.*%((%d+), (%d+)%%, (%d+)%%.*%)")
if start ~= nil then
red, green, blue = hslToRgb(tonumber(hue), tonumber(saturation),
tonumber(lightness))
red, green, blue =
hslToRgb(tonumber(hue), tonumber(saturation), tonumber(lightness))
hl = rgbToHex(red, green, blue)
end

View File

@ -8,11 +8,11 @@ return {
return {
window = {
open = "alternate"
open = "alternate",
},
one_per = {
wezterm = false,
kitty = false
kitty = false,
},
callbacks = {
should_block = function(argv)
@ -49,7 +49,7 @@ return {
once = true,
callback = vim.schedule_wrap(function()
vim.api.nvim_buf_delete(bufnr, {})
end)
end),
})
end
end,
@ -61,9 +61,9 @@ return {
saved_terminal = nil
end
end)
end
}
end,
},
}
end
}
end,
},
}

View File

@ -28,9 +28,9 @@ return {
asm = function()
return {
exe = "asmfmt",
stdin = true
stdin = true,
}
end
end,
},
}
end,

View File

@ -1,12 +1,12 @@
return {
{
'pwntester/octo.nvim',
"pwntester/octo.nvim",
cmd = "Octo",
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
'nvim-tree/nvim-web-devicons',
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
"nvim-tree/nvim-web-devicons",
},
config = true
}
config = true,
},
}

View File

@ -142,11 +142,11 @@ return {
local filename = self.filename
local extension = vim.fn.fnamemodify(filename, ":e")
local buftype = vim.api.nvim_get_option_value("buftype", {
buf = self.bufnr
buf = self.bufnr,
})
local filetype = vim.api.nvim_get_option_value("filetype", {
buf = self.bufnr
buf = self.bufnr,
})
self.icon, self.icon_color =
require("nvim-web-devicons").get_icon_color(filename, extension, { default = true })
@ -155,11 +155,11 @@ return {
["rust"] = { icon = "", icon_color = self.icon_color },
["sshconfig"] = { icon = "󰴳", icon_color = colors.carpYellow },
["sshdconfig"] = "sshconfig",
["help"] = { icon = "󰋗", icon_color = colors.springGreen }
["help"] = { icon = "󰋗", icon_color = colors.springGreen },
}
local buftype_overrides = {
["terminal"] = { icon = "", icon_color = colors.roninYellow }
["terminal"] = { icon = "", icon_color = colors.roninYellow },
}
local function get_override(name, overrides)
@ -194,7 +194,7 @@ return {
provider = function(self)
local filename = ""
local buftype = vim.api.nvim_get_option_value("buftype", {
buf = self.bufnr
buf = self.bufnr,
})
if buftype == "terminal" then
local subs = 0
@ -455,7 +455,7 @@ return {
StatusLineBufferBlock,
{ provider = "", hl = { fg = colors.katanaGray } }, -- left truncation, optional (defaults to "<")
{ provider = "", hl = { fg = colors.katanaGray } } -- right trunctation, also optional (defaults to ...... yep, ">")
-- by the way, open a lot of buffers and try clicking them ;)
-- by the way, open a lot of buffers and try clicking them ;)
)
local Tabpage = {
@ -562,7 +562,7 @@ return {
end
return { fg = colors.oniViolet, bg = bg }
end
end,
},
},
{
@ -589,7 +589,7 @@ return {
return { fg = colors.oniViolet2, bg = bg }
end,
},
}
},
},
{
condition = conditions.has_diagnostics,
@ -676,7 +676,7 @@ return {
},
{
FileIcon,
hl = { bg = colors.sumiInk4 }
hl = { bg = colors.sumiInk4 },
},
{
provider = seps.full.right,

View File

@ -1,9 +1,9 @@
return {
{
'tzachar/highlight-undo.nvim',
"tzachar/highlight-undo.nvim",
keys = {
{"u"},
{"<C-r>"}
{ "u" },
{ "<C-r>" },
},
opts = {},
},

View File

@ -9,7 +9,7 @@ return {
},
keys = {
{ "<leader>h", desc = "> Hydra" },
{ "<C-w>" }
{ "<C-w>" },
},
event = { "BufReadPre", "BufNewFile" },
config = function()

View File

@ -212,9 +212,9 @@ return {
vim.cmd.colorscheme("kanagawa")
local colors = require("kanagawa.colors").setup().palette
vim.api.nvim_set_hl(0, "StatusLine", { bg = colors.sumiInk0 })
vim.api.nvim_set_hl(0, "WinBar", { bg = nil })
vim.api.nvim_set_hl(0, "WinBar", { bg = nil })
vim.api.nvim_set_hl(0, "StatusLineNC", { bg = nil })
vim.api.nvim_set_hl(0, "WinBarNC", { bg = nil })
vim.api.nvim_set_hl(0, "WinBarNC", { bg = nil })
end,
},
}

View File

@ -462,16 +462,17 @@ return {
require("typescript-tools").setup({
on_attach = on_attach,
settings = {
tsserver_path = vim.fn.stdpath("data") .. "/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js",
tsserver_path = vim.fn.stdpath("data")
.. "/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js",
expose_as_code_action = {
"fix_all",
"add_missing_imports",
"remove_unused",
"remove_unused_imports",
"organize_imports"
"organize_imports",
},
tsserver_plugins = {
"@styled/typescript-styled-plugin"
"@styled/typescript-styled-plugin",
},
tsserver_file_preferences = {
includeInlayParameterNameHints = "all",
@ -497,11 +498,10 @@ return {
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
}
}
}
}
)
},
},
},
})
-- NOTE: GENERIC LSP SERVERS
for _, server in ipairs({

View File

@ -11,30 +11,30 @@ return {
":Telescope diagnostics bufnr=0<CR>",
desc = "LSP: Telescope Diagnostics",
},
{ "<leader>t", desc = "> Telescope" },
{ "<leader>tg", desc = "> Telescope: Git" },
{ "<leader>tw", ":Telescope live_grep<CR>", desc = "Telescope: Grep for Word" },
{ "<leader>tgs", ":Telescope git_status<CR>", desc = "Telescope: Git Status" },
{ "<leader>tgc", ":Telescope git_commits<CR>", desc = "Telescope: Git Commits" },
{ "<leader>tgb", ":Telescope git_branches<CR>", desc = "Telescope: Git Branches" },
{ "<leader>tf", ":Telescope find_files<CR>", desc = "Telescope: Find Files" },
{ "<leader>td", ":Telescope find_directories<CR>", desc = "Telescope: Find Directories" },
{ "<leader>tb", ":Telescope buffers<CR>", desc = "Telescope: Buffers" },
{ "<leader>th", ":Telescope help_tags<CR>", desc = "Telescope: Help Tags" },
{ "<leader>to", ":Telescope oldfiles<CR>", desc = "Telescope: Recent Files" },
{ "<leader>tn", ":Telescope neoclip default<CR>", desc = "Telescope: Neoclip Buffer" },
{ "<leader>tr", ":Telescope resume<CR>", desc = "Telescope: Resume" },
{ "<leader>tR", ":Telescope registers<CR>", desc = "Telescope: Registers" },
{ "<leader>tt", ":Telescope file_browser<CR>", desc = "Telescope: File Tree" },
{ "<leader>ts", ":Telescope spell_suggest<CR>", desc = "Telescope: Spell Suggest" },
{ "<leader>tl", ":Telescope resume<CR>", desc = "Telescope: Previous State" },
{ "<leader>tT", ":TodoTelescope<CR>", desc = "Telescope: Todo Items" },
{ "<leader>tk", ":Telescope keymaps<CR>", desc = "Telescope: Keymaps" },
{ "<leader>tc", ":Telescope commands<CR>", desc = "Telescope: Commands" },
{ "<leader>tu", ":Telescope undo<CR>", desc = "Telescope: Undo History" },
{ "<leader>tm", ":Telescope man_pages<CR>", desc = "Telescope: Man Pages" },
{ "<leader>lq", ":Telescope diagnostics bufnr=0<CR>", desc = "LSP: Telescope Diagnostics" },
{ "<leader>nv", ":Telescope notify<CR>", desc = "Notifications: Search" },
{ "<leader>t", desc = "> Telescope" },
{ "<leader>tg", desc = "> Telescope: Git" },
{ "<leader>tw", ":Telescope live_grep<CR>", desc = "Telescope: Grep for Word" },
{ "<leader>tgs", ":Telescope git_status<CR>", desc = "Telescope: Git Status" },
{ "<leader>tgc", ":Telescope git_commits<CR>", desc = "Telescope: Git Commits" },
{ "<leader>tgb", ":Telescope git_branches<CR>", desc = "Telescope: Git Branches" },
{ "<leader>tf", ":Telescope find_files<CR>", desc = "Telescope: Find Files" },
{ "<leader>td", ":Telescope find_directories<CR>", desc = "Telescope: Find Directories" },
{ "<leader>tb", ":Telescope buffers<CR>", desc = "Telescope: Buffers" },
{ "<leader>th", ":Telescope help_tags<CR>", desc = "Telescope: Help Tags" },
{ "<leader>to", ":Telescope oldfiles<CR>", desc = "Telescope: Recent Files" },
{ "<leader>tn", ":Telescope neoclip default<CR>", desc = "Telescope: Neoclip Buffer" },
{ "<leader>tr", ":Telescope resume<CR>", desc = "Telescope: Resume" },
{ "<leader>tR", ":Telescope registers<CR>", desc = "Telescope: Registers" },
{ "<leader>tt", ":Telescope file_browser<CR>", desc = "Telescope: File Tree" },
{ "<leader>ts", ":Telescope spell_suggest<CR>", desc = "Telescope: Spell Suggest" },
{ "<leader>tl", ":Telescope resume<CR>", desc = "Telescope: Previous State" },
{ "<leader>tT", ":TodoTelescope<CR>", desc = "Telescope: Todo Items" },
{ "<leader>tk", ":Telescope keymaps<CR>", desc = "Telescope: Keymaps" },
{ "<leader>tc", ":Telescope commands<CR>", desc = "Telescope: Commands" },
{ "<leader>tu", ":Telescope undo<CR>", desc = "Telescope: Undo History" },
{ "<leader>tm", ":Telescope man_pages<CR>", desc = "Telescope: Man Pages" },
{ "<leader>lq", ":Telescope diagnostics bufnr=0<CR>", desc = "LSP: Telescope Diagnostics" },
{ "<leader>nv", ":Telescope notify<CR>", desc = "Notifications: Search" },
},
dependencies = {
"nvim-telescope/telescope-file-browser.nvim",
@ -43,7 +43,7 @@ return {
"debugloop/telescope-undo.nvim",
"rcarriga/nvim-notify",
{ "nvim-telescope/telescope-smart-history.nvim", dependencies = "tami5/sqlite.lua" },
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
},
config = function()
local telescope = require("telescope")
@ -179,7 +179,7 @@ return {
"Wikipedia",
("https://en.wikipedia.org/w/index.php?search=" .. search:gsub(" ", "+")),
},
{ "Github", ("https://github.com/search?q=" .. search:gsub(" ", "+")) },
{ "Github", ("https://github.com/search?q=" .. search:gsub(" ", "+")) },
},
entry_maker = function(entry)
return { value = entry, display = entry[1], ordinal = entry[1] }
@ -193,9 +193,14 @@ return {
---@param obj vim.SystemCompleted
vim.system({ "xdg-open", selection["value"][2] }, { text = true }, function(obj)
if obj.code ~= 0 then
vim.notify(string.format(
"Failed to open selection, exit code: %s!\n---Stdout---\n%s\n---Stderr---\n%s",
obj.code, obj.stdout, obj.stderr))
vim.notify(
string.format(
"Failed to open selection, exit code: %s!\n---Stdout---\n%s\n---Stderr---\n%s",
obj.code,
obj.stdout,
obj.stderr
)
)
end
end)
end)

View File

@ -22,7 +22,7 @@ return {
vim.cmd.ToggleTerm()
end
end,
desc = "ToggleTerm: Toggle"
desc = "ToggleTerm: Toggle",
},
},
opts = {

View File

@ -122,7 +122,7 @@ return {
},
"JoosepAlviste/nvim-ts-context-commentstring",
"nvim-treesitter/nvim-treesitter-textobjects",
"RRethy/nvim-treesitter-endwise"
"RRethy/nvim-treesitter-endwise",
},
config = function()
local treesitter_dir = vim.fn.stdpath("data") .. "/treesitter"
@ -180,7 +180,7 @@ return {
enable = true,
},
endwise = {
enable = true
enable = true,
},
textobjects = {
select = {
@ -234,7 +234,6 @@ return {
},
include_surrounding_whitespace = true,
},
})
end,
},

View File

@ -51,5 +51,4 @@ U.title_case = function(str)
return string.gsub(str, "(%a)([%w_']*)", inner)
end
return U