nvim: use consistent style for lua files
This commit is contained in:
parent
b1361e85a5
commit
aaa3b3236e
22 changed files with 156 additions and 220 deletions
|
@ -7,27 +7,21 @@ M.setup = function()
|
||||||
desc = "Briefly highlight yanked text.",
|
desc = "Briefly highlight yanked text.",
|
||||||
group = group,
|
group = group,
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function(_)
|
callback = function(_) vim.highlight.on_yank() end,
|
||||||
vim.highlight.on_yank()
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||||
desc = "Hide cursor line when entering insert mode.",
|
desc = "Hide cursor line when entering insert mode.",
|
||||||
group = group,
|
group = group,
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function(_)
|
callback = function(_) vim.opt.cursorlineopt = "number" end,
|
||||||
vim.opt.cursorlineopt = "number"
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||||
desc = "Show cursor line when leaving insert mode.",
|
desc = "Show cursor line when leaving insert mode.",
|
||||||
group = group,
|
group = group,
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function(_)
|
callback = function(_) vim.opt.cursorlineopt = "both" end,
|
||||||
vim.opt.cursorlineopt = "both"
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,7 @@ end
|
||||||
|
|
||||||
---Show diagnostics in a floating window.
|
---Show diagnostics in a floating window.
|
||||||
---@param opts table|nil: options passed along to `vim.diagnostic.open_float`.
|
---@param opts table|nil: options passed along to `vim.diagnostic.open_float`.
|
||||||
M.open_float = function(opts)
|
M.open_float = function(opts) vim.diagnostic.open_float(opts) end
|
||||||
vim.diagnostic.open_float(opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Toggle diagnostics in the given buffer.
|
---Toggle diagnostics in the given buffer.
|
||||||
---@param bufnr integer|nil: Buffer number (0 for current buffer, nil for all buffers.
|
---@param bufnr integer|nil: Buffer number (0 for current buffer, nil for all buffers.
|
||||||
|
@ -54,9 +52,7 @@ end
|
||||||
|
|
||||||
---Hide currently displayed diagnostics.
|
---Hide currently displayed diagnostics.
|
||||||
---@param bufnr integer|nil: Buffer number (0 for current buffer, nil for all buffers.
|
---@param bufnr integer|nil: Buffer number (0 for current buffer, nil for all buffers.
|
||||||
M.hide = function(bufnr)
|
M.hide = function(bufnr) vim.diagnostic.hide(nil, bufnr or 0) end
|
||||||
vim.diagnostic.hide(nil, bufnr or 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.select_virtual_text_severity = function()
|
M.select_virtual_text_severity = function()
|
||||||
vim.ui.select(
|
vim.ui.select(
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
return {
|
return {
|
||||||
"norcalli/nvim-colorizer.lua",
|
"norcalli/nvim-colorizer.lua",
|
||||||
|
|
||||||
cond = function(_)
|
cond = function(_) return vim.o.termguicolors end,
|
||||||
return vim.o.termguicolors
|
|
||||||
end,
|
|
||||||
|
|
||||||
event = { "BufNewFile", "BufReadPost" },
|
event = { "BufNewFile", "BufReadPost" },
|
||||||
|
|
||||||
|
@ -12,7 +10,5 @@ return {
|
||||||
mode = "foreground",
|
mode = "foreground",
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function(_, opts)
|
config = function(_, opts) require("colorizer").setup(nil, opts) end,
|
||||||
require("colorizer").setup(nil, opts)
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,7 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
style = "night",
|
style = "night",
|
||||||
dim_inactive = true,
|
dim_inactive = true,
|
||||||
on_colors = function(colors)
|
on_colors = function(colors) colors.bg_highlight = "#1d212f" end,
|
||||||
colors.bg_highlight = "#1d212f"
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
local make_keymap = function(cmp)
|
local make_keymap = function(cmp)
|
||||||
local if_visible = function(yes, no)
|
local if_visible = function(yes, no)
|
||||||
no = no or function(fallback)
|
no = no or function(fallback) fallback() end
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
return function(fallback)
|
return function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
yes(fallback)
|
yes(fallback)
|
||||||
|
@ -12,19 +10,19 @@ local make_keymap = function(cmp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local m = cmp.mapping
|
||||||
local select = { behavior = cmp.SelectBehavior.Select }
|
local select = { behavior = cmp.SelectBehavior.Select }
|
||||||
local next_or_complete = if_visible(cmp.mapping.select_next_item(select), cmp.mapping.complete())
|
local next_or_complete = if_visible(m.select_next_item(select), m.complete())
|
||||||
local prev_or_complete = if_visible(cmp.mapping.select_prev_item(select), cmp.mapping.complete())
|
local prev_or_complete = if_visible(m.select_prev_item(select), m.complete())
|
||||||
local next = if_visible(cmp.mapping.select_next_item(select))
|
local next = if_visible(m.select_next_item(select))
|
||||||
local prev = if_visible(cmp.mapping.select_prev_item(select))
|
local prev = if_visible(m.select_prev_item(select))
|
||||||
|
|
||||||
local abort = if_visible(cmp.mapping.abort())
|
local abort = if_visible(m.abort())
|
||||||
local confirm = if_visible(cmp.mapping.confirm { select = true })
|
local confirm = if_visible(m.confirm { select = true })
|
||||||
local confirm_or_complete =
|
local confirm_or_complete = if_visible(m.confirm { select = true }, m.complete())
|
||||||
if_visible(cmp.mapping.confirm { select = true }, cmp.mapping.complete())
|
|
||||||
|
|
||||||
local scroll_docs_down = cmp.mapping.scroll_docs(3)
|
local scroll_docs_down = m.scroll_docs(3)
|
||||||
local scroll_docs_up = cmp.mapping.scroll_docs(-3)
|
local scroll_docs_up = m.scroll_docs(-3)
|
||||||
|
|
||||||
-- Mappings that should work in both command line and Insert mode.
|
-- Mappings that should work in both command line and Insert mode.
|
||||||
return {
|
return {
|
||||||
|
@ -76,13 +74,12 @@ return {
|
||||||
|
|
||||||
enabled = function()
|
enabled = function()
|
||||||
local ctx = require("cmp.config.context")
|
local ctx = require("cmp.config.context")
|
||||||
return not ctx.in_treesitter_capture("comment") and not ctx.in_syntax_group("Comment")
|
return not ctx.in_treesitter_capture("comment")
|
||||||
|
and not ctx.in_syntax_group("Comment")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args) require("luasnip").lsp_expand(args.body) end,
|
||||||
require("luasnip").lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
formatting = {
|
formatting = {
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
---@return function
|
---@return function
|
||||||
local dial_cmd = function(cmd, suffix)
|
local dial_cmd = function(cmd, suffix)
|
||||||
suffix = suffix or ""
|
suffix = suffix or ""
|
||||||
return function()
|
return function() return require("dial.map")[cmd]() .. suffix end
|
||||||
return require("dial.map")[cmd]() .. suffix
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Make a new augend that cycles over the given elements.
|
---Make a new augend that cycles over the given elements.
|
||||||
|
@ -30,9 +28,7 @@ local weekdays = {
|
||||||
"Sunday",
|
"Sunday",
|
||||||
}
|
}
|
||||||
|
|
||||||
local weekdays_short = vim.tbl_map(function(s)
|
local weekdays_short = vim.tbl_map(function(s) return s:sub(1, 3) end, weekdays)
|
||||||
return s:sub(1, 3)
|
|
||||||
end, weekdays)
|
|
||||||
|
|
||||||
local ui = require("fschauen.util.icons").ui
|
local ui = require("fschauen.util.icons").ui
|
||||||
local inc, dec = ui.Increment, ui.Decrement
|
local inc, dec = ui.Increment, ui.Decrement
|
||||||
|
|
|
@ -22,17 +22,17 @@ local shfmt = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local toggle_format_on_write = (function()
|
local toggle_format_on_write = (function()
|
||||||
local augroup_id = nil
|
local augroup = nil
|
||||||
return function()
|
return function()
|
||||||
if augroup_id then
|
if augroup then
|
||||||
vim.api.nvim_del_augroup_by_id(augroup_id)
|
vim.api.nvim_del_augroup_by_id(augroup)
|
||||||
augroup_id = nil
|
augroup = nil
|
||||||
vim.notify("Format on write DISABLED", vim.log.levels.WARN)
|
vim.notify("Format on write DISABLED", vim.log.levels.WARN)
|
||||||
else
|
else
|
||||||
augroup_id = vim.api.nvim_create_augroup("fschauen.format_on_write", { clear = true })
|
augroup = vim.api.nvim_create_augroup("fschauen.format_on_write", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
desc = "Format files on write.",
|
desc = "Format files on write.",
|
||||||
group = augroup_id,
|
group = augroup,
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
command = ":FormatWrite",
|
command = ":FormatWrite",
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,7 +18,13 @@ return {
|
||||||
|
|
||||||
require("headlines").setup {
|
require("headlines").setup {
|
||||||
markdown = {
|
markdown = {
|
||||||
headline_highlights = { "Headline1", "Headline2", "Headline3", "Headline4", "Headline5" },
|
headline_highlights = {
|
||||||
|
"Headline1",
|
||||||
|
"Headline2",
|
||||||
|
"Headline3",
|
||||||
|
"Headline4",
|
||||||
|
"Headline5",
|
||||||
|
},
|
||||||
bullets = "",
|
bullets = "",
|
||||||
dash_string = "",
|
dash_string = "",
|
||||||
fat_headlines = false,
|
fat_headlines = false,
|
||||||
|
|
|
@ -12,7 +12,10 @@ end
|
||||||
local lsp_handlers = function()
|
local lsp_handlers = function()
|
||||||
return {
|
return {
|
||||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, border),
|
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, border),
|
||||||
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, border),
|
["textDocument/signatureHelp"] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.signature_help,
|
||||||
|
border
|
||||||
|
),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,9 +88,7 @@ local server_opts = setmetatable({
|
||||||
}, {
|
}, {
|
||||||
-- The default is a just a passthrough of the options.
|
-- The default is a just a passthrough of the options.
|
||||||
__index = function()
|
__index = function()
|
||||||
return function(opts)
|
return function(opts) return opts end
|
||||||
return opts
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,36 @@
|
||||||
local M = { 'nvim-lualine/lualine.nvim' }
|
local M = { "nvim-lualine/lualine.nvim" }
|
||||||
|
|
||||||
local icons = require('fschauen.util.icons')
|
local icons = require("fschauen.util.icons")
|
||||||
local ui = icons.ui
|
local ui = icons.ui
|
||||||
|
|
||||||
local orange = '#d65d0e'
|
local orange = "#d65d0e"
|
||||||
local bright = '#ffffff' -- alternative: '#f9f5d7'
|
local bright = "#ffffff" -- alternative: '#f9f5d7'
|
||||||
|
|
||||||
M.dependencies = 'nvim-tree/nvim-web-devicons'
|
M.dependencies = "nvim-tree/nvim-web-devicons"
|
||||||
|
|
||||||
M.config = function(--[[plugin]]_, --[[opts]]_)
|
M.config = function()
|
||||||
local window = require 'fschauen.window'
|
local window = require("fschauen.window")
|
||||||
|
|
||||||
local filename = (function()
|
local filename = (function()
|
||||||
local C = require('lualine.component'):extend()
|
local C = require("lualine.component"):extend()
|
||||||
|
|
||||||
function C:init(options)
|
function C:init(options)
|
||||||
C.super.init(self, options)
|
C.super.init(self, options)
|
||||||
|
|
||||||
local color = options.color or {}
|
local color = options.color or {}
|
||||||
local modified = { gui = 'italic' }
|
local modified = { gui = "italic" }
|
||||||
|
|
||||||
self.custom_highlights = { -- [is_focused, modified]
|
self.custom_highlights = { -- [is_focused, modified]
|
||||||
[true] = {
|
[true] = {
|
||||||
[true] = self:create_hl(vim.tbl_extend('force', color, modified), 'focus_modified'),
|
[true] = self:create_hl(
|
||||||
[false] = self:create_hl(color, 'focus'),
|
vim.tbl_extend("force", color, modified),
|
||||||
|
"focus_modified"
|
||||||
|
),
|
||||||
|
[false] = self:create_hl(color, "focus"),
|
||||||
},
|
},
|
||||||
[false] = {
|
[false] = {
|
||||||
[true] = self:create_hl(modified, 'nofocus_modified'),
|
[true] = self:create_hl(modified, "nofocus_modified"),
|
||||||
[false] = self:create_hl({}, 'nofocus'),
|
[false] = self:create_hl({}, "nofocus"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -35,14 +38,14 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
|
||||||
function C:update_status(is_focused)
|
function C:update_status(is_focused)
|
||||||
self.options.color_highlight = self.custom_highlights[is_focused][vim.bo.modified]
|
self.options.color_highlight = self.custom_highlights[is_focused][vim.bo.modified]
|
||||||
|
|
||||||
local path = vim.fn.expand('%:~:.')
|
local path = vim.fn.expand("%:~:.")
|
||||||
|
|
||||||
if window.is_wide() then
|
if window.is_wide() then
|
||||||
return path
|
return path
|
||||||
elseif window.is_medium() then
|
elseif window.is_medium() then
|
||||||
return vim.fn.pathshorten(path) -- only first letter of directories
|
return vim.fn.pathshorten(path) -- only first letter of directories
|
||||||
else
|
else
|
||||||
return vim.fn.fnamemodify(path, ':t') -- only tail
|
return vim.fn.fnamemodify(path, ":t") -- only tail
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,68 +53,69 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
local mode = (function()
|
local mode = (function()
|
||||||
local C = require('lualine.component'):extend()
|
local C = require("lualine.component"):extend()
|
||||||
|
|
||||||
C.map = {
|
C.map = {
|
||||||
['n'] = icons.modes.Normal, -- 'Normal ', -- Normal
|
["n"] = icons.modes.Normal, -- 'Normal ', -- Normal
|
||||||
['no'] = icons.modes.OperatorPending, -- 'O-Pend ', -- Operator-pending
|
["no"] = icons.modes.OperatorPending, -- 'O-Pend ', -- Operator-pending
|
||||||
['ni'] = icons.modes.NormalI, -- 'Normal ', -- Normal via i_CTRL-O
|
["ni"] = icons.modes.NormalI, -- 'Normal ', -- Normal via i_CTRL-O
|
||||||
['v'] = icons.modes.Visual, -- 'Visual ', -- Visual by character
|
["v"] = icons.modes.Visual, -- 'Visual ', -- Visual by character
|
||||||
[''] = icons.modes.VisualBlock, -- 'V-Block', -- Visual blockwise
|
[""] = icons.modes.VisualBlock, -- 'V-Block', -- Visual blockwise
|
||||||
['s'] = icons.modes.Select, -- 'Select ', -- Select by character
|
["s"] = icons.modes.Select, -- 'Select ', -- Select by character
|
||||||
[''] = icons.modes.SelectBlock, -- 'S-Block', -- Select blockwise
|
[""] = icons.modes.SelectBlock, -- 'S-Block', -- Select blockwise
|
||||||
['i'] = icons.modes.Insert, -- 'Insert ', -- Insert
|
["i"] = icons.modes.Insert, -- 'Insert ', -- Insert
|
||||||
['r'] = icons.modes.Replace, -- 'Replace', -- Replace
|
["r"] = icons.modes.Replace, -- 'Replace', -- Replace
|
||||||
['rv'] = icons.modes.VirtualReplace, -- 'V-Repl ', -- Virtual Replace
|
["rv"] = icons.modes.VirtualReplace, -- 'V-Repl ', -- Virtual Replace
|
||||||
['c'] = icons.modes.Command, -- 'Command', -- Command-line
|
["c"] = icons.modes.Command, -- 'Command', -- Command-line
|
||||||
['cv'] = icons.modes.Ex, -- ' Ex ', -- Ex mode
|
["cv"] = icons.modes.Ex, -- ' Ex ', -- Ex mode
|
||||||
['rm'] = icons.modes.modeore, -- ' modeore ', -- -- modeORE --
|
["rm"] = icons.modes.modeore, -- ' modeore ', -- -- modeORE --
|
||||||
['r?'] = icons.modes.Cofirm, -- 'Confirm', -- :confirm
|
["r?"] = icons.modes.Cofirm, -- 'Confirm', -- :confirm
|
||||||
['!'] = icons.modes.Shell, -- ' Shell ', -- External command executing
|
["!"] = icons.modes.Shell, -- ' Shell ', -- External command executing
|
||||||
['t'] = icons.modes.Term, -- ' Term ', -- Terminal
|
["t"] = icons.modes.Term, -- ' Term ', -- Terminal
|
||||||
}
|
}
|
||||||
|
|
||||||
function C:update_status(is_focused)
|
function C:update_status(is_focused)
|
||||||
if not is_focused then return ' ' .. ui.Sleep end
|
if not is_focused then return " " .. ui.Sleep end
|
||||||
|
|
||||||
local code = vim.api.nvim_get_mode().mode:lower()
|
local code = vim.api.nvim_get_mode().mode:lower()
|
||||||
local symbol = C.map[code:sub(1, 2)] or C.map[code:sub(1, 1)] or code
|
local symbol = C.map[code:sub(1, 2)] or C.map[code:sub(1, 1)] or code
|
||||||
return ' ' .. symbol .. ' '
|
return " " .. symbol .. " "
|
||||||
end
|
end
|
||||||
|
|
||||||
return C
|
return C
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
local searchcount = (function()
|
local searchcount = (function()
|
||||||
local C = require('lualine.component'):extend()
|
local C = require("lualine.component"):extend()
|
||||||
|
|
||||||
function C:init(options)
|
function C:init(options)
|
||||||
C.super.init(self, options)
|
C.super.init(self, options)
|
||||||
self.options = vim.tbl_extend('keep', self.options or {}, {
|
self.options = vim.tbl_extend("keep", self.options or {}, {
|
||||||
maxcount = 999,
|
maxcount = 999,
|
||||||
timeout = 250,
|
timeout = 250,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:update_status()
|
function C:update_status()
|
||||||
if vim.v.hlsearch == 0 then return '' end
|
if vim.v.hlsearch == 0 then return "" end
|
||||||
|
|
||||||
local count = vim.fn.searchcount {
|
local count = vim.fn.searchcount {
|
||||||
maxcount = self.options.maxcount,
|
maxcount = self.options.maxcount,
|
||||||
timeout = self.options.timeout
|
timeout = self.options.timeout,
|
||||||
}
|
}
|
||||||
if next(count) == nil then return '' end
|
if next(count) == nil then return "" end
|
||||||
|
|
||||||
local denominator = count.total > count.maxcount and '' or string.format('%d', count.total)
|
local denominator = count.total > count.maxcount and ""
|
||||||
return string.format(ui.Search .. '%d/%s', count.current, denominator)
|
or string.format("%d", count.total)
|
||||||
|
return string.format(ui.Search .. "%d/%s", count.current, denominator)
|
||||||
end
|
end
|
||||||
|
|
||||||
return C
|
return C
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
local colored_if_focused = function(component)
|
local colored_if_focused = function(component)
|
||||||
if type(component) == 'string' then
|
if type(component) == "string" then
|
||||||
local C = require('lualine.components.' .. component):extend()
|
local C = require("lualine.components." .. component):extend()
|
||||||
|
|
||||||
function C:update_status(is_focused)
|
function C:update_status(is_focused)
|
||||||
self.options.colored = is_focused
|
self.options.colored = is_focused
|
||||||
|
@ -119,9 +123,8 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
|
||||||
end
|
end
|
||||||
|
|
||||||
return C
|
return C
|
||||||
|
elseif type(component) == "function" then
|
||||||
elseif type(component) == 'function' then
|
local C = require("lualine.component"):extend()
|
||||||
local C = require('lualine.component'):extend()
|
|
||||||
|
|
||||||
function C:init(options)
|
function C:init(options)
|
||||||
C.super.init(self, options)
|
C.super.init(self, options)
|
||||||
|
@ -140,35 +143,33 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
|
||||||
local trailing_whitespace = {
|
local trailing_whitespace = {
|
||||||
colored_if_focused(function()
|
colored_if_focused(function()
|
||||||
local trailing = [[\s\+$]]
|
local trailing = [[\s\+$]]
|
||||||
local lineno = vim.fn.search(trailing, 'nwc')
|
local lineno = vim.fn.search(trailing, "nwc")
|
||||||
if lineno == 0 then return '' end
|
if lineno == 0 then return "" end
|
||||||
|
|
||||||
local result = ui.Attention .. lineno
|
local result = ui.Attention .. lineno
|
||||||
|
|
||||||
local total = vim.fn.searchcount({ pattern = trailing }).total
|
local total = vim.fn.searchcount({ pattern = trailing }).total
|
||||||
if total > 1 then result = result .. string.format(' (%d total)', total) end
|
if total > 1 then result = result .. string.format(" (%d total)", total) end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end),
|
end),
|
||||||
|
|
||||||
color = { bg = orange },
|
color = { bg = orange },
|
||||||
|
|
||||||
cond = function()
|
cond = function() return vim.bo.filetype ~= "help" end,
|
||||||
return vim.bo.filetype ~= 'help'
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local paste = {
|
local paste = {
|
||||||
colored_if_focused(function(has_focus) return has_focus and ui.Paste or ' ' end),
|
colored_if_focused(function(has_focus) return has_focus and ui.Paste or " " end),
|
||||||
color = {
|
color = {
|
||||||
bg = orange,
|
bg = orange,
|
||||||
},
|
},
|
||||||
cond = function() return vim.o.paste end
|
cond = function() return vim.o.paste end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local status = {
|
local status = {
|
||||||
colored_if_focused(function(_)
|
colored_if_focused(function(_)
|
||||||
local status = ''
|
local status = ""
|
||||||
if vim.bo.modified then status = status .. ui.Modified end
|
if vim.bo.modified then status = status .. ui.Modified end
|
||||||
if vim.bo.readonly or not vim.bo.modifiable then status = status .. ui.ReadOnly end
|
if vim.bo.readonly or not vim.bo.modifiable then status = status .. ui.ReadOnly end
|
||||||
return status
|
return status
|
||||||
|
@ -181,51 +182,51 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
|
||||||
local sections = {
|
local sections = {
|
||||||
lualine_a = {
|
lualine_a = {
|
||||||
paste,
|
paste,
|
||||||
mode
|
mode,
|
||||||
},
|
},
|
||||||
lualine_b = {
|
lualine_b = {
|
||||||
{ 'branch', icon = icons.git.Branch, cond = window.is_medium },
|
{ "branch", icon = icons.git.Branch, cond = window.is_medium },
|
||||||
},
|
},
|
||||||
lualine_c = {
|
lualine_c = {
|
||||||
filename,
|
filename,
|
||||||
status,
|
status,
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
colored_if_focused('diagnostics'),
|
colored_if_focused("diagnostics"),
|
||||||
searchcount,
|
searchcount,
|
||||||
{ colored_if_focused('filetype'), cond = window.is_medium },
|
{ colored_if_focused("filetype"), cond = window.is_medium },
|
||||||
},
|
},
|
||||||
lualine_y = {
|
lualine_y = {
|
||||||
{ 'fileformat', cond = window.is_medium },
|
{ "fileformat", cond = window.is_medium },
|
||||||
'progress',
|
"progress",
|
||||||
},
|
},
|
||||||
lualine_z = {
|
lualine_z = {
|
||||||
'location',
|
"location",
|
||||||
trailing_whitespace,
|
trailing_whitespace,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require('lualine').setup {
|
require("lualine").setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
component_separators = {
|
component_separators = {
|
||||||
left = '',
|
left = "",
|
||||||
right = ''
|
right = "",
|
||||||
},
|
},
|
||||||
section_separators = {
|
section_separators = {
|
||||||
left = '',
|
left = "",
|
||||||
right = ''
|
right = "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sections = sections,
|
sections = sections,
|
||||||
inactive_sections = sections,
|
inactive_sections = sections,
|
||||||
extensions = {
|
extensions = {
|
||||||
'fugitive',
|
"fugitive",
|
||||||
'quickfix',
|
"quickfix",
|
||||||
'nvim-tree',
|
"nvim-tree",
|
||||||
'lazy',
|
"lazy",
|
||||||
'man',
|
"man",
|
||||||
'trouble',
|
"trouble",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
return {
|
return {
|
||||||
"iamcco/markdown-preview.nvim",
|
"iamcco/markdown-preview.nvim",
|
||||||
|
|
||||||
build = function()
|
build = function() vim.fn["mkdp#util#install"]() end,
|
||||||
vim.fn["mkdp#util#install"]()
|
|
||||||
end,
|
|
||||||
|
|
||||||
cmd = {
|
cmd = {
|
||||||
"MarkdownPreview",
|
"MarkdownPreview",
|
||||||
|
|
|
@ -6,9 +6,7 @@ return {
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>L",
|
"<leader>L",
|
||||||
function()
|
function() require("lint").try_lint() end,
|
||||||
require("lint").try_lint()
|
|
||||||
end,
|
|
||||||
desc = icon .. " [L]int file",
|
desc = icon .. " [L]int file",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,9 +15,7 @@ local telescope_notifications = function()
|
||||||
telescope.load_extension("notify").notify(theme)
|
telescope.load_extension("notify").notify(theme)
|
||||||
end
|
end
|
||||||
|
|
||||||
local dismiss_notifications = function()
|
local dismiss_notifications = function() require("notify").dismiss() end
|
||||||
require("notify").dismiss()
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"rcarriga/nvim-notify",
|
"rcarriga/nvim-notify",
|
||||||
|
|
|
@ -18,7 +18,5 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
init = function()
|
init = function() vim.g.openbrowser_default_search = "duckduckgo" end,
|
||||||
vim.g.openbrowser_default_search = "duckduckgo"
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,12 @@ return {
|
||||||
dependencies = "nvim-telescope/telescope.nvim",
|
dependencies = "nvim-telescope/telescope.nvim",
|
||||||
|
|
||||||
keys = {
|
keys = {
|
||||||
{ lhs("B"), "<cmd>Telescope file_browser theme=ivy<cr>", desc = desc("file [B]rowser") },
|
{
|
||||||
|
lhs("B"),
|
||||||
|
"<cmd>Telescope file_browser theme=ivy<cr>",
|
||||||
|
desc = desc("file [B]rowser"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function() require("telescope").load_extension("file_browser") end,
|
||||||
require("telescope").load_extension("file_browser")
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
local ui = require("fschauen.util.icons").ui
|
local ui = require("fschauen.util.icons").ui
|
||||||
|
|
||||||
---Create the left hand side for a Telescope keymap.
|
---Create the left hand side for a Telescope keymap.
|
||||||
local lhs = function(keys)
|
local lhs = function(keys) return "<leader>f" .. keys end
|
||||||
return "<leader>f" .. keys
|
|
||||||
end
|
|
||||||
|
|
||||||
---Create the description for a Telescope keymap.
|
---Create the description for a Telescope keymap.
|
||||||
local desc = function(text)
|
local desc = function(text) return ui.Telescope .. " Telescope " .. text end
|
||||||
return ui.Telescope .. " Telescope " .. text
|
|
||||||
end
|
|
||||||
|
|
||||||
local builtin_picker = function(name, opts)
|
local builtin_picker = function(name, opts)
|
||||||
return function(title)
|
return function(title)
|
||||||
|
@ -43,9 +39,7 @@ local pickers = setmetatable({
|
||||||
}, {
|
}, {
|
||||||
-- Fall back to telescope's built-in pickers if a custom one is not defined
|
-- Fall back to telescope's built-in pickers if a custom one is not defined
|
||||||
-- above, but make sure to keep the title we defined.
|
-- above, but make sure to keep the title we defined.
|
||||||
__index = function(_, key)
|
__index = function(_, key) return builtin_picker(key) end,
|
||||||
return builtin_picker(key)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
local icon = require("fschauen.util.icons").ui.Text
|
local icon = require("fschauen.util.icons").ui.Text
|
||||||
local description = icon .." [c]hange text [c]ase"
|
local description = icon .. " [c]hange text [c]ase"
|
||||||
|
|
||||||
local theme = function()
|
local theme = function() return require("telescope.themes").get_cursor() end
|
||||||
return require("telescope.themes").get_cursor()
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"johmsalas/text-case.nvim",
|
"johmsalas/text-case.nvim",
|
||||||
|
@ -20,9 +18,7 @@ return {
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>cc",
|
"<leader>cc",
|
||||||
function()
|
function() require("telescope").extensions.textcase.normal_mode(theme()) end,
|
||||||
require("telescope").extensions.textcase.normal_mode(theme())
|
|
||||||
end,
|
|
||||||
mode = "n",
|
mode = "n",
|
||||||
desc = description,
|
desc = description,
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,9 +22,7 @@ end
|
||||||
---Get selected text.
|
---Get selected text.
|
||||||
---@return string: selected text, or word under cursor if not in visual mode.
|
---@return string: selected text, or word under cursor if not in visual mode.
|
||||||
M.get_selected_text = function()
|
M.get_selected_text = function()
|
||||||
if vim.fn.mode() ~= "v" then
|
if vim.fn.mode() ~= "v" then return vim.fn.expand("<cword>") end
|
||||||
return vim.fn.expand("<cword>")
|
|
||||||
end
|
|
||||||
|
|
||||||
return M.preserve_register("v", function()
|
return M.preserve_register("v", function()
|
||||||
vim.cmd([[noautocmd sil norm "vy]])
|
vim.cmd([[noautocmd sil norm "vy]])
|
||||||
|
|
|
@ -12,9 +12,7 @@ local find_module_sources = function(modname)
|
||||||
for _, directory in ipairs(vim.opt.runtimepath:get()) do
|
for _, directory in ipairs(vim.opt.runtimepath:get()) do
|
||||||
for _, candidate in ipairs(candidates) do
|
for _, candidate in ipairs(candidates) do
|
||||||
local path = directory .. "/" .. candidate
|
local path = directory .. "/" .. candidate
|
||||||
if exists(path) then
|
if exists(path) then table.insert(results, path) end
|
||||||
table.insert(results, path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return results
|
return results
|
||||||
|
@ -51,9 +49,7 @@ M.go_to_module = function(modname)
|
||||||
vim.cmd.edit(sources[1])
|
vim.cmd.edit(sources[1])
|
||||||
else
|
else
|
||||||
vim.ui.select(sources, { prompt = "Which one?" }, function(choice)
|
vim.ui.select(sources, { prompt = "Which one?" }, function(choice)
|
||||||
if choice then
|
if choice then vim.cmd.edit(choice) end
|
||||||
vim.cmd.edit(choice)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,8 +27,8 @@ end
|
||||||
|
|
||||||
M.set_gitcommit_buffer_options = function()
|
M.set_gitcommit_buffer_options = function()
|
||||||
vim.bo.textwidth = 72
|
vim.bo.textwidth = 72
|
||||||
vim.opt.formatoptions:append('t') -- wrap text on 'textwidth'
|
vim.opt.formatoptions:append("t") -- wrap text on 'textwidth'
|
||||||
vim.opt.spell = true -- turn on spell checking
|
vim.opt.spell = true -- turn on spell checking
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -3,16 +3,12 @@ local M = {}
|
||||||
---Determine whether the window is wide.
|
---Determine whether the window is wide.
|
||||||
---@param win_nr integer|nil: window number or window-ID, 0 for current window.
|
---@param win_nr integer|nil: window number or window-ID, 0 for current window.
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.is_wide = function(win_nr)
|
M.is_wide = function(win_nr) return vim.fn.winwidth(win_nr or 0) > 80 end
|
||||||
return vim.fn.winwidth(win_nr or 0) > 80
|
|
||||||
end
|
|
||||||
|
|
||||||
---Determine whether the window is medium.
|
---Determine whether the window is medium.
|
||||||
---@param win_nr integer|nil: window number or window-ID, 0 for current window.
|
---@param win_nr integer|nil: window number or window-ID, 0 for current window.
|
||||||
---@return boolean
|
---@return boolean
|
||||||
M.is_medium = function(win_nr)
|
M.is_medium = function(win_nr) return vim.fn.winwidth(win_nr or 0) > 50 end
|
||||||
return vim.fn.winwidth(win_nr or 0) > 50
|
|
||||||
end
|
|
||||||
|
|
||||||
---Whether the current window is the last in a given direction.
|
---Whether the current window is the last in a given direction.
|
||||||
---@param direction string: one of 'h', 'j', 'k', or 'l'
|
---@param direction string: one of 'h', 'j', 'k', or 'l'
|
||||||
|
@ -22,9 +18,7 @@ local is_last = function(direction)
|
||||||
local next = vim.api.nvim_get_current_win()
|
local next = vim.api.nvim_get_current_win()
|
||||||
|
|
||||||
local is_last = current == next
|
local is_last = current == next
|
||||||
if not is_last then
|
if not is_last then vim.cmd("wincmd p") end
|
||||||
vim.cmd("wincmd p")
|
|
||||||
end
|
|
||||||
|
|
||||||
return is_last
|
return is_last
|
||||||
end
|
end
|
||||||
|
@ -33,17 +27,13 @@ end
|
||||||
---@param dir string: one of 'h', 'j', 'k', or 'l'
|
---@param dir string: one of 'h', 'j', 'k', or 'l'
|
||||||
---@param size integer: how much to resize
|
---@param size integer: how much to resize
|
||||||
local resize = function(dir, size)
|
local resize = function(dir, size)
|
||||||
if dir ~= "h" and dir ~= "j" and dir ~= "k" and dir ~= "l" then
|
if dir ~= "h" and dir ~= "j" and dir ~= "k" and dir ~= "l" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
size = math.abs(size)
|
size = math.abs(size)
|
||||||
local is_height = dir == "j" or dir == "k"
|
local is_height = dir == "j" or dir == "k"
|
||||||
local is_positive = dir == "j" or dir == "l"
|
local is_positive = dir == "j" or dir == "l"
|
||||||
|
|
||||||
if is_last(is_height and "j" or "l") then
|
if is_last(is_height and "j" or "l") then is_positive = not is_positive end
|
||||||
is_positive = not is_positive
|
|
||||||
end
|
|
||||||
|
|
||||||
local delta = string.format("%s%d", is_positive and "+" or "-", size)
|
local delta = string.format("%s%d", is_positive and "+" or "-", size)
|
||||||
local prefix = is_height and "" or "vertical "
|
local prefix = is_height and "" or "vertical "
|
||||||
|
@ -53,63 +43,45 @@ end
|
||||||
---Resize current window upwards.
|
---Resize current window upwards.
|
||||||
---@param size integer: how much to resize
|
---@param size integer: how much to resize
|
||||||
M.resize_up = function(size)
|
M.resize_up = function(size)
|
||||||
return function()
|
return function() resize("k", size) end
|
||||||
resize("k", size)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Resize current window downwards.
|
---Resize current window downwards.
|
||||||
---@param size integer: how much to resize
|
---@param size integer: how much to resize
|
||||||
M.resize_down = function(size)
|
M.resize_down = function(size)
|
||||||
return function()
|
return function() resize("j", size) end
|
||||||
resize("j", size)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Resize current window leftwards.
|
---Resize current window leftwards.
|
||||||
---@param size integer: how much to resize
|
---@param size integer: how much to resize
|
||||||
M.resize_left = function(size)
|
M.resize_left = function(size)
|
||||||
return function()
|
return function() resize("h", size) end
|
||||||
resize("h", size)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Resize current window rightwards.
|
---Resize current window rightwards.
|
||||||
---@param size integer: how much to resize
|
---@param size integer: how much to resize
|
||||||
M.resize_right = function(size)
|
M.resize_right = function(size)
|
||||||
return function()
|
return function() resize("l", size) end
|
||||||
resize("l", size)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Toggle quickfix (or location) list.
|
---Toggle quickfix (or location) list.
|
||||||
---@param qf string: 'c' for quickfix, 'l' for location list
|
---@param qf string: 'c' for quickfix, 'l' for location list
|
||||||
local toggle_list = function(qf)
|
local toggle_list = function(qf)
|
||||||
local l = qf == "l" and 1 or 0
|
local l = qf == "l" and 1 or 0
|
||||||
local is_qf = function(win)
|
local is_qf = function(win) return win.quickfix == 1 and win.loclist == l end
|
||||||
return win.quickfix == 1 and win.loclist == l
|
|
||||||
end
|
|
||||||
local is_open = not vim.tbl_isempty(vim.tbl_filter(is_qf, vim.fn.getwininfo()))
|
local is_open = not vim.tbl_isempty(vim.tbl_filter(is_qf, vim.fn.getwininfo()))
|
||||||
if is_open then
|
if is_open then
|
||||||
vim.cmd(qf .. "close")
|
vim.cmd(qf .. "close")
|
||||||
else
|
else
|
||||||
local ok = pcall(function(c)
|
local ok = pcall(function(c) vim.cmd(c) end, qf .. "open")
|
||||||
vim.cmd(c)
|
if not ok and qf == "l" then vim.notify("No location list", vim.log.levels.WARN) end
|
||||||
end, qf .. "open")
|
|
||||||
if not ok and qf == "l" then
|
|
||||||
vim.notify("No location list", vim.log.levels.WARN)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Toggle quickfix list.
|
---Toggle quickfix list.
|
||||||
M.toggle_quickfix = function()
|
M.toggle_quickfix = function() toggle_list("c") end
|
||||||
toggle_list("c")
|
|
||||||
end
|
|
||||||
|
|
||||||
---Toggle location list.
|
---Toggle location list.
|
||||||
M.toggle_loclist = function()
|
M.toggle_loclist = function() toggle_list("l") end
|
||||||
toggle_list("l")
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
column_width = 100
|
column_width = 90
|
||||||
|
line_endings = "Unix"
|
||||||
indent_type = "Spaces"
|
indent_type = "Spaces"
|
||||||
indent_width = 2
|
indent_width = 2
|
||||||
quote_style = "AutoPreferDouble"
|
quote_style = "AutoPreferDouble"
|
||||||
call_parentheses = "NoSingleTable"
|
call_parentheses = "NoSingleTable"
|
||||||
collapse_simple_statement = "Never"
|
collapse_simple_statement = "Always"
|
||||||
|
|
Loading…
Add table
Reference in a new issue