vim: enforce style in top-level code
This commit is contained in:
parent
f513e9346e
commit
fe084ae46a
8 changed files with 232 additions and 220 deletions
|
@ -1,29 +1,34 @@
|
|||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
local group = vim.api.nvim_create_augroup('fschauen', { clear = true } )
|
||||
local group = vim.api.nvim_create_augroup("fschauen", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
desc = 'Briefly highlight yanked text.',
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
desc = "Briefly highlight yanked text.",
|
||||
group = group,
|
||||
pattern = '*',
|
||||
callback = function(_) vim.highlight.on_yank() end
|
||||
pattern = "*",
|
||||
callback = function(_)
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('InsertEnter', {
|
||||
desc = 'Hide cursor line when entering insert mode.',
|
||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
desc = "Hide cursor line when entering insert mode.",
|
||||
group = group,
|
||||
pattern = '*',
|
||||
callback = function(_) vim.opt.cursorlineopt = 'number' end
|
||||
pattern = "*",
|
||||
callback = function(_)
|
||||
vim.opt.cursorlineopt = "number"
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('InsertLeave', {
|
||||
desc = 'Show cursor line when leaving insert mode.',
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
desc = "Show cursor line when leaving insert mode.",
|
||||
group = group,
|
||||
pattern = '*',
|
||||
callback = function(_) vim.opt.cursorlineopt = 'both' end
|
||||
pattern = "*",
|
||||
callback = function(_)
|
||||
vim.opt.cursorlineopt = "both"
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local M = {}
|
||||
|
||||
local icons = require('fschauen.util.icons')
|
||||
local icons = require("fschauen.util.icons")
|
||||
|
||||
-- Show/navigate warning and errors by default.
|
||||
M.severity = vim.diagnostic.severity.WARN
|
||||
|
@ -8,38 +8,38 @@ M.severity = vim.diagnostic.severity.WARN
|
|||
-- Go to next/prev diagnostic, but only if next item has a visible virtual text.
|
||||
-- If we can move, then also center screen at target location.
|
||||
local conditional_goto = function(condition, move, opts)
|
||||
opts = vim.tbl_extend('keep', opts or {}, {
|
||||
opts = vim.tbl_extend("keep", opts or {}, {
|
||||
wrap = false, -- don't wrap around the begin/end of file
|
||||
severity = { -- only navigate items with visible virtual text
|
||||
min = M.severity
|
||||
min = M.severity,
|
||||
},
|
||||
})
|
||||
|
||||
if condition(opts) then
|
||||
move(opts)
|
||||
vim.cmd 'normal zz'
|
||||
vim.cmd("normal zz")
|
||||
else
|
||||
vim.notify(
|
||||
('No more diagnostics [level: %s]'):format(vim.diagnostic.severity[M.severity] or '???'),
|
||||
vim.log.levels.WARN)
|
||||
local level = vim.diagnostic.severity[M.severity] or "???"
|
||||
local msg = string.format("No more diagnostics [level: %s]", level)
|
||||
vim.notify(msg, vim.log.levels.WARN)
|
||||
end
|
||||
end
|
||||
|
||||
---Move to the next diagnostic.
|
||||
---@param opts table\nil: options passed along to `vim.diagnostic.goto_next`.
|
||||
M.goto_next= function(opts)
|
||||
M.goto_next = function(opts)
|
||||
conditional_goto(vim.diagnostic.get_next_pos, vim.diagnostic.goto_next, opts)
|
||||
end
|
||||
|
||||
---Move to the previous diagnostic.
|
||||
---@param opts table|nil: options passed along to `vim.diagnostic.goto_prev`.
|
||||
M.goto_prev= function(opts)
|
||||
M.goto_prev = function(opts)
|
||||
conditional_goto(vim.diagnostic.get_prev_pos, vim.diagnostic.goto_prev, opts)
|
||||
end
|
||||
|
||||
---Show diagnostics in a floating window.
|
||||
---@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
|
||||
|
||||
|
@ -62,18 +62,19 @@ end
|
|||
|
||||
M.select_virtual_text_severity = function()
|
||||
vim.ui.select(
|
||||
{ 'ERROR', 'WARN', 'INFO', 'HINT' },
|
||||
{ prompt = 'Min. severity for virtual text:' },
|
||||
function(choice, --[[index]]_)
|
||||
{ "ERROR", "WARN", "INFO", "HINT" },
|
||||
{ prompt = "Min. severity for virtual text:" },
|
||||
function(choice)
|
||||
if choice then
|
||||
M.severity = vim.diagnostic.severity[choice] or M.severity
|
||||
vim.diagnostic.config {
|
||||
virtual_text = {
|
||||
severity = { min = M.severity }
|
||||
severity = { min = M.severity },
|
||||
},
|
||||
}
|
||||
end
|
||||
end)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
---Customize nvim's diagnostics display.
|
||||
|
@ -85,19 +86,18 @@ M.setup = function()
|
|||
prefix = icons.ui.Circle,
|
||||
severity = {
|
||||
min = M.severity,
|
||||
}
|
||||
},
|
||||
},
|
||||
float = {
|
||||
border = 'rounded',
|
||||
border = "rounded",
|
||||
},
|
||||
severity_sort = true,
|
||||
}
|
||||
|
||||
for type, icon in pairs(icons.diagnostics) do
|
||||
local hl = 'DiagnosticSign' .. type
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ local M = {}
|
|||
M.setup = function()
|
||||
vim.filetype.add {
|
||||
pattern = {
|
||||
['${HOME}/.ssh/config.d/.*'] = 'sshconfig',
|
||||
['.*/ssh/config'] = 'sshconfig',
|
||||
['.*/git/config'] = 'gitconfig',
|
||||
['.*config/zsh/.*'] = 'zsh',
|
||||
}
|
||||
["${HOME}/.ssh/config.d/.*"] = "sshconfig",
|
||||
[".*/ssh/config"] = "sshconfig",
|
||||
[".*/git/config"] = "gitconfig",
|
||||
[".*config/zsh/.*"] = "zsh",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
|
|
@ -4,17 +4,16 @@ P = function(v)
|
|||
end
|
||||
|
||||
R = function(module)
|
||||
require('plenary.reload').reload_module(module)
|
||||
require("plenary.reload").reload_module(module)
|
||||
return require(module)
|
||||
end
|
||||
|
||||
require('fschauen.options').setup()
|
||||
require('fschauen.keymap').setup()
|
||||
require('fschauen.diagnostic').setup()
|
||||
require('fschauen.autocmd').setup()
|
||||
require('fschauen.filetype').setup()
|
||||
require('fschauen.lazy').setup()
|
||||
|
||||
local colorscheme = vim.env.NVIM_COLORSCHEME or 'gruvbox'
|
||||
vim.cmd('silent! colorscheme ' .. colorscheme)
|
||||
require("fschauen.options").setup()
|
||||
require("fschauen.keymap").setup()
|
||||
require("fschauen.diagnostic").setup()
|
||||
require("fschauen.autocmd").setup()
|
||||
require("fschauen.filetype").setup()
|
||||
require("fschauen.lazy").setup()
|
||||
|
||||
local colorscheme = vim.env.NVIM_COLORSCHEME or "gruvbox"
|
||||
vim.cmd("silent! colorscheme " .. colorscheme)
|
||||
|
|
|
@ -1,123 +1,124 @@
|
|||
local M = {}
|
||||
|
||||
local ui = require('fschauen.util.icons').ui
|
||||
local ui = require("fschauen.util.icons").ui
|
||||
|
||||
local map = function(mode, lhs, rhs, opts)
|
||||
if mode ~= 'c' then
|
||||
if mode ~= "c" then
|
||||
opts = opts or {}
|
||||
opts.silent = opts.silent ~= false -- silent by default
|
||||
end
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
-- stylua: ignore start
|
||||
M.setup = function()
|
||||
-- better navigation for wrapped lines
|
||||
map('n', 'j', 'gj')
|
||||
map('n', 'k', 'gk')
|
||||
map("n", "j", "gj")
|
||||
map("n", "k", "gk")
|
||||
|
||||
-- maintain cursor position when joining lines
|
||||
map('n', 'J', 'mzJ`z')
|
||||
map("n", "J", "mzJ`z")
|
||||
|
||||
-- retain selection when making changes in visual mode
|
||||
map('v', '<c-a>', '<c-a>gv')
|
||||
map('v', '<c-x>', '<c-x>gv')
|
||||
map('v', 'g<c-a>', 'g<c-a>gv')
|
||||
map('v', 'g<c-x>', 'g<c-x>gv')
|
||||
map('v', '>', '><cr>gv')
|
||||
map('v', '<', '<<cr>gv')
|
||||
map("v", "<c-a>", "<c-a>gv")
|
||||
map("v", "<c-x>", "<c-x>gv")
|
||||
map("v", "g<c-a>", "g<c-a>gv")
|
||||
map("v", "g<c-x>", "g<c-x>gv")
|
||||
map("v", ">", "><cr>gv")
|
||||
map("v", "<", "<<cr>gv")
|
||||
|
||||
-- place destination of important movements in the center of the screen
|
||||
map('n', 'n', 'nzzzv')
|
||||
map('n', 'N', 'Nzzzv')
|
||||
map('n', '*', '*zzzv')
|
||||
map('n', '#', '#zzzv')
|
||||
map('n', 'g*', 'g*zzzv')
|
||||
map('n', 'g#', 'g#zzzv')
|
||||
map('n', '<c-d>', '<c-d>zzzv')
|
||||
map('n', '<c-u>', '<c-u>zzzv')
|
||||
map("n", "n", "nzzzv")
|
||||
map("n", "N", "Nzzzv")
|
||||
map("n", "*", "*zzzv")
|
||||
map("n", "#", "#zzzv")
|
||||
map("n", "g*", "g*zzzv")
|
||||
map("n", "g#", "g#zzzv")
|
||||
map("n", "<c-d>", "<c-d>zzzv")
|
||||
map("n", "<c-u>", "<c-u>zzzv")
|
||||
|
||||
-- easier window navigation
|
||||
map('n', '<c-j>', '<c-w>j')
|
||||
map('n', '<c-k>', '<c-w>k')
|
||||
map('n', '<c-h>', '<c-w>h')
|
||||
map('n', '<c-l>', '<c-w>l')
|
||||
map("n", "<c-j>", "<c-w>j")
|
||||
map("n", "<c-k>", "<c-w>k")
|
||||
map("n", "<c-h>", "<c-w>h")
|
||||
map("n", "<c-l>", "<c-w>l")
|
||||
|
||||
local window = require 'fschauen.window'
|
||||
|
||||
-- window resizing
|
||||
map('n', '<s-Up>', window.resize_up(2), { desc = 'Resize window upward' })
|
||||
map('n', '<s-Down>', window.resize_down(2), { desc = 'Resize window downward' })
|
||||
map('n', '<s-Left>', window.resize_left(2), { desc = 'Resize window leftward' })
|
||||
map('n', '<s-Right>', window.resize_right(2), { desc = 'Resize window rightward' })
|
||||
map("n", "<s-Up>", window.resize_up(2), { desc = "Resize window upward" })
|
||||
map("n", "<s-Down>", window.resize_down(2), { desc = "Resize window downward" })
|
||||
map("n", "<s-Left>", window.resize_left(2), { desc = "Resize window leftward" })
|
||||
map("n", "<s-Right>", window.resize_right(2), { desc = "Resize window rightward" })
|
||||
|
||||
-- easy tab navigation
|
||||
map('n', '<Right>', '<cmd>tabnext<cr>')
|
||||
map('n', '<Left>', '<cmd>tabprevious<cr>')
|
||||
map("n", "<Right>", "<cmd>tabnext<cr>")
|
||||
map("n", "<Left>", "<cmd>tabprevious<cr>")
|
||||
|
||||
-- move lines up and down
|
||||
map('n', '<c-a-j>', [[:move .+1<cr>==]])
|
||||
map('n', '<c-a-k>', [[:move .-2<cr>==]])
|
||||
map('v', '<c-a-j>', [[:move '>+1<cr>gv=gv]])
|
||||
map('v', '<c-a-k>', [[:move '<-2<cr>gv=gv]])
|
||||
map('i', '<c-a-j>', [[<esc>:move .+1<cr>==gi]])
|
||||
map('i', '<c-a-k>', [[<esc>:move .-2<cr>==gi]])
|
||||
map("n", "<c-a-j>", [[:move .+1<cr>==]])
|
||||
map("n", "<c-a-k>", [[:move .-2<cr>==]])
|
||||
map("v", "<c-a-j>", [[:move '>+1<cr>gv=gv]])
|
||||
map("v", "<c-a-k>", [[:move '<-2<cr>gv=gv]])
|
||||
map("i", "<c-a-j>", [[<esc>:move .+1<cr>==gi]])
|
||||
map("i", "<c-a-k>", [[<esc>:move .-2<cr>==gi]])
|
||||
|
||||
-- move to begin/end of line in insert mode
|
||||
map('i', '<c-a>', '<c-o>^')
|
||||
map('i', '<c-e>', '<c-o>$')
|
||||
map("i", "<c-a>", "<c-o>^")
|
||||
map("i", "<c-e>", "<c-o>$")
|
||||
|
||||
-- move to begin of line in command mode (<c-e> moves to end by default)
|
||||
map('c', '<c-a>', '<c-b>')
|
||||
map("c", "<c-a>", "<c-b>")
|
||||
|
||||
-- more convenient way of entering normal mode from terminal mode
|
||||
map('t', [[<c-\><c-\>]], [[<c-\><c-n>]])
|
||||
map("t", [[<c-\><c-\>]], [[<c-\><c-n>]])
|
||||
|
||||
-- recall older/recent command-line from history
|
||||
map('c', '<c-j>', '<down>')
|
||||
map('c', '<c-k>', '<up>')
|
||||
map("c", "<c-j>", "<down>")
|
||||
map("c", "<c-k>", "<up>")
|
||||
|
||||
-- trigger InsertLeave when leaving Insert mode with ctrl-c (see :help i_CTRL-C)
|
||||
map('i', '<c-c>', '<esc>')
|
||||
map("i", "<c-c>", "<esc>")
|
||||
|
||||
-- quickly change background
|
||||
map('n', '<leader>bg', [[<cmd>let &background = &background ==? 'light' ? 'dark' : 'light'<cr>]])
|
||||
map("n", "<leader>bg", [[<cmd>let &background = &background ==? "light" ? "dark" : "light"<cr>]])
|
||||
|
||||
-- don't loose the original yanked contents when pasting in visual mode
|
||||
map('x', '<leader>p', [["_dP]])
|
||||
map("x", "<leader>p", [["_dP]])
|
||||
|
||||
local diagnostic = require 'fschauen.diagnostic'
|
||||
|
||||
-- navigate diagnostics
|
||||
map('n', '<Down>', diagnostic.goto_next, { desc = ui.Diagnostic .. ' [d]iagnostic [n]ext' })
|
||||
map('n', '<Up>', diagnostic.goto_prev, { desc = ui.Diagnostic .. ' [d]iagnostic [p]revious' })
|
||||
map('n', '<leader>dd', diagnostic.toggle, { desc = ui.Diagnostic .. ' [d]iagnostic enable/[d]isable' })
|
||||
map('n', '<leader>do', diagnostic.open_float, { desc = ui.Diagnostic .. ' [d]iagnostic [o]pen' })
|
||||
map('n', '<leader>dh', diagnostic.hide, { desc = ui.Diagnostic .. ' [d]iagnostic [h]ide' })
|
||||
map('n', '<leader>ds', diagnostic.select_virtual_text_severity, { desc = ui.Diagnostic .. ' [d]iagnostic [s]everity' })
|
||||
map("n", "<Down>", diagnostic.goto_next, { desc = ui.Diagnostic .. " [d]iagnostic [n]ext" })
|
||||
map("n", "<Up>", diagnostic.goto_prev, { desc = ui.Diagnostic .. " [d]iagnostic [p]revious" })
|
||||
map("n", "<leader>dd", diagnostic.toggle, { desc = ui.Diagnostic .. " [d]iagnostic enable/[d]isable" })
|
||||
map("n", "<leader>do", diagnostic.open_float, { desc = ui.Diagnostic .. " [d]iagnostic [o]pen" })
|
||||
map("n", "<leader>dh", diagnostic.hide, { desc = ui.Diagnostic .. " [d]iagnostic [h]ide" })
|
||||
map("n", "<leader>ds", diagnostic.select_virtual_text_severity, { desc = ui.Diagnostic .. " [d]iagnostic [s]everity" })
|
||||
|
||||
-- disable highlight until next search
|
||||
map('n', '<leader>h', '<cmd>nohlsearch<cr><esc>')
|
||||
map("n", "<leader>h", "<cmd>nohlsearch<cr><esc>")
|
||||
|
||||
-- navigate items in quickfix and location lists
|
||||
map('n', '<leader>j', '<cmd>cnext<cr>zz')
|
||||
map('n', '<leader>k', '<cmd>cprevious<cr>zz')
|
||||
map('n', '<localleader>j', '<cmd>lnext<cr>zz')
|
||||
map('n', '<localleader>k', '<cmd>lprevious<cr>zz')
|
||||
map("n", "<leader>j", "<cmd>cnext<cr>zz")
|
||||
map("n", "<leader>k", "<cmd>cprevious<cr>zz")
|
||||
map("n", "<localleader>j", "<cmd>lnext<cr>zz")
|
||||
map("n", "<localleader>k", "<cmd>lprevious<cr>zz")
|
||||
|
||||
|
||||
-- toggle quickfix and loclist
|
||||
map('n', '<leader>ll', window.toggle_quickfix, { desc = ui.Toggle .. ' toggle quickfix' })
|
||||
map('n', '<localleader>ll', window.toggle_loclist, { desc = ui.Toggle .. ' toggle loclist' })
|
||||
map("n", "<leader>ll", window.toggle_quickfix, { desc = ui.Toggle .. " toggle quickfix" })
|
||||
map("n", "<localleader>ll", window.toggle_loclist, { desc = ui.Toggle .. " toggle loclist" })
|
||||
|
||||
local options = require('fschauen.util.options')
|
||||
|
||||
-- toggle options
|
||||
map('n', '<leader>sn', options.toggle_number, { desc = ui.Toggle .. " toggle 'number'" })
|
||||
map('n', '<leader>sr', options.toggle_relativenumber, { desc = ui.Toggle .. " toggle 'relativenumber'" })
|
||||
map('n', '<leader>sl', options.toggle_list, { desc = ui.Toggle .. " toggle 'list'" })
|
||||
map('n', '<leader>sw', options.toggle_wrap, { desc = ui.Toggle .. " toggle 'wrap'" })
|
||||
map('n', '<leader>ss', options.toggle_spell, { desc = ui.Toggle .. " toggle 'spell'" })
|
||||
map("n", "<leader>sn", options.toggle_number, { desc = ui.Toggle .. " toggle 'number'" })
|
||||
map("n", "<leader>sr", options.toggle_relativenumber, { desc = ui.Toggle .. " toggle 'relativenumber'" })
|
||||
map("n", "<leader>sl", options.toggle_list, { desc = ui.Toggle .. " toggle 'list'" })
|
||||
map("n", "<leader>sw", options.toggle_wrap, { desc = ui.Toggle .. " toggle 'wrap'" })
|
||||
map("n", "<leader>ss", options.toggle_spell, { desc = ui.Toggle .. " toggle 'spell'" })
|
||||
end
|
||||
-- stylua: ignore end
|
||||
|
||||
return M
|
||||
|
||||
|
|
|
@ -3,22 +3,22 @@ local M = {}
|
|||
local bootstrap = function(path)
|
||||
if not vim.loop.fs_stat(path) then
|
||||
vim.fn.system {
|
||||
'git',
|
||||
'clone',
|
||||
'--filter=blob:none',
|
||||
'--branch=stable',
|
||||
'https://github.com/folke/lazy.nvim.git',
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"--branch=stable",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
path,
|
||||
}
|
||||
end
|
||||
vim.opt.rtp:prepend(path)
|
||||
return vim.F.npcall(require, 'lazy')
|
||||
return vim.F.npcall(require, "lazy")
|
||||
end
|
||||
|
||||
local dev_path = function()
|
||||
local paths = {
|
||||
'~/Projects/nvim-plugins',
|
||||
'~/.local/src',
|
||||
"~/Projects/nvim-plugins",
|
||||
"~/.local/src",
|
||||
}
|
||||
paths = vim.tbl_map(vim.fn.expand, paths)
|
||||
paths = vim.tbl_filter(vim.loop.fs_stat, paths)
|
||||
|
@ -26,35 +26,35 @@ local dev_path = function()
|
|||
end
|
||||
|
||||
M.setup = function()
|
||||
local lazy = bootstrap(vim.fn.stdpath('data') .. '/lazy/lazy.nvim')
|
||||
local lazy = bootstrap(vim.fn.stdpath("data") .. "/lazy/lazy.nvim")
|
||||
if not lazy then
|
||||
vim.notify('Lazy not installed and failed to bootstrap!', vim.log.levels.WARN)
|
||||
vim.notify("Lazy not installed and failed to bootstrap!", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<leader>L', '<cmd>Lazy<cr>')
|
||||
vim.keymap.set("n", "<leader>L", "<cmd>Lazy<cr>")
|
||||
|
||||
lazy.setup {
|
||||
spec = 'fschauen.plugins',
|
||||
spec = "fschauen.plugins",
|
||||
dev = {
|
||||
path = dev_path(),
|
||||
fallback = true,
|
||||
},
|
||||
ui = {
|
||||
border = 'rounded',
|
||||
title = ' Lazy ',
|
||||
border = "rounded",
|
||||
title = " Lazy ",
|
||||
},
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
'gzip',
|
||||
'matchit',
|
||||
'matchparen',
|
||||
'netrwPlugin',
|
||||
'tarPlugin',
|
||||
'tohtml',
|
||||
'tutor',
|
||||
'zipPlugin',
|
||||
"gzip",
|
||||
"matchit",
|
||||
"matchparen",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
local M = {}
|
||||
|
||||
-- stylua: ignore start
|
||||
M.setup = function()
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ','
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = ","
|
||||
|
||||
vim.cmd [[let &t_8f = "\<ESC>[38:2:%lu:%lu:%lum"]]
|
||||
vim.cmd [[let &t_8b = "\<ESC>[48:2:%lu:%lu:%lum"]]
|
||||
|
@ -10,21 +11,21 @@ M.setup = function()
|
|||
local o = vim.opt
|
||||
|
||||
-- General
|
||||
o.belloff = 'all' -- never ring bells
|
||||
o.belloff = "all" -- never ring bells
|
||||
o.hidden = true -- hide abandoned buffers
|
||||
o.clipboard = 'unnamedplus' -- synchronize with system clipboard
|
||||
o.lazyredraw = true -- don't redraw screen during macros
|
||||
o.clipboard = "unnamedplus" -- synchronize with system clipboard
|
||||
o.lazyredraw = true -- don"t redraw screen during macros
|
||||
o.modelines = 0 -- never use modelines
|
||||
o.fileformats = 'unix,mac,dos' -- prioritize unix <EOL> format
|
||||
o.pastetoggle = '<F20>' -- toggle paste with P on Moonlander
|
||||
o.fileformats = "unix,mac,dos" -- prioritize unix <EOL> format
|
||||
o.pastetoggle = "<F20>" -- toggle paste with P on Moonlander
|
||||
o.winblend = 8 -- minimum transparency for floating windows
|
||||
|
||||
o.swapfile = false -- don't use swap files
|
||||
o.swapfile = false -- don"t use swap files
|
||||
o.writebackup = true -- Make a backup before writing a file...
|
||||
o.backup = false -- ...but don't keep it around.
|
||||
o.backup = false -- ...but don"t keep it around.
|
||||
o.undofile = true -- write undo history
|
||||
|
||||
o.shortmess:append 'I' -- no intro message when starting Vim
|
||||
o.shortmess:append("I") -- no intro message when starting Vim
|
||||
o.shada = {
|
||||
"'1000", -- remember marks for this many files
|
||||
"/1000", -- remember this many search patterns
|
||||
|
@ -44,29 +45,29 @@ M.setup = function()
|
|||
o.tabstop = 4 -- tabs are 4 spaces
|
||||
o.shiftwidth = 0 -- (auto)indent using 'tabstop' spaces
|
||||
o.smartindent = true -- use smart autoindenting
|
||||
o.inccommand = 'split' -- preview command partial results
|
||||
o.inccommand = "split" -- preview command partial results
|
||||
o.joinspaces = false -- use one space after a period whe joining lines
|
||||
o.showmatch = true -- briefly jump to matching bracket if insert one
|
||||
o.virtualedit = 'block' -- position the cursor anywhere in Visual Block mode
|
||||
o.virtualedit = "block" -- position the cursor anywhere in Visual Block mode
|
||||
o.formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]]
|
||||
o.completeopt = {
|
||||
'menu', -- show completions in a popup menu
|
||||
'preview', -- show extra information about the selected match
|
||||
'noinsert', -- don't insert text until I select a match
|
||||
'noselect', -- don't pre-select the first match in the menu
|
||||
"menu", -- show completions in a popup menu
|
||||
"preview", -- show extra information about the selected match
|
||||
"noinsert", -- don"t insert text until I select a match
|
||||
"noselect", -- don"t pre-select the first match in the menu
|
||||
}
|
||||
|
||||
local fmt = o.formatoptions
|
||||
fmt:remove 't' -- Don't auto-wrap on 'textwidth'...
|
||||
fmt:append 'c' -- ...but do it within comment blocks...
|
||||
fmt:append 'l' -- ...but not if line was already long before entering Insert mode.
|
||||
fmt:append 'r' -- Insert comment leader when pressing Enter...
|
||||
fmt:remove 'o' -- ...but not when opening a new line with o & O.
|
||||
fmt:append 'q' -- allow formatting of comments with gq
|
||||
fmt:remove 'a' -- don't auto-format every time text is inserted
|
||||
fmt:append 'n' -- indent lists automatically acc. 'formatlistpat'
|
||||
fmt:append 'j' -- remove comment leader when joining lines
|
||||
fmt:append '1' -- don't break lines after a one letter word but rather before it
|
||||
fmt:remove("t") -- Don't auto-wrap on 'textwidth'...
|
||||
fmt:append("c") -- ...but do it within comment blocks...
|
||||
fmt:append("l") -- ...but not if line was already long before entering Insert mode.
|
||||
fmt:append("r") -- Insert comment leader when pressing Enter...
|
||||
fmt:remove("o") -- ...but not when opening a new line with o & O.
|
||||
fmt:append("q") -- allow formatting of comments with gq
|
||||
fmt:remove("a") -- don"t auto-format every time text is inserted
|
||||
fmt:append("n") -- indent lists automatically acc. 'formatlistpat'
|
||||
fmt:append("j") -- remove comment leader when joining lines
|
||||
fmt:append("1") -- don"t break lines after a one letter word but rather before it
|
||||
|
||||
-- Appearance
|
||||
o.termguicolors = true -- use "gui" :higlight instead of "cterm"
|
||||
|
@ -75,49 +76,49 @@ M.setup = function()
|
|||
o.number = true -- ...but real number for current line.
|
||||
o.wrap = false -- don't wrap long lines initially
|
||||
o.textwidth = 80 -- maximum width for text being inserted
|
||||
o.colorcolumn = '' -- highlight column after 'textwidth'
|
||||
o.colorcolumn = "" -- highlight column after 'textwidth'
|
||||
o.cursorline = true -- highlight the line of the cursor
|
||||
o.showbreak = '⤷ ' -- prefix for wrapped lines
|
||||
o.showbreak = "⤷ " -- prefix for wrapped lines
|
||||
o.scrolloff = 3 -- min. # of lines above and below cursor
|
||||
o.sidescrolloff = 3 -- min. # of columns to left and right of cursor
|
||||
o.signcolumn = 'yes' -- always display the signs column
|
||||
o.signcolumn = "yes" -- always display the signs column
|
||||
o.list = false -- don't show invisible characters initially
|
||||
o.listchars = {
|
||||
eol = '↲',
|
||||
tab = ' ', -- »
|
||||
extends = '…',
|
||||
precedes = '…',
|
||||
trail = '·',
|
||||
conceal = '┊',
|
||||
eol = "↲",
|
||||
tab = " ", -- »
|
||||
extends = "…",
|
||||
precedes = "…",
|
||||
trail = "·",
|
||||
conceal = "┊",
|
||||
}
|
||||
o.fillchars = {
|
||||
diff = '⋅',
|
||||
diff = "⋅",
|
||||
}
|
||||
|
||||
-- Wildcard Expansion
|
||||
o.wildignore = {
|
||||
'.git',
|
||||
'.svn',
|
||||
'__pycache__',
|
||||
'**/tmp/**',
|
||||
'*.DS_Store',
|
||||
'*.dll',
|
||||
'*.egg-info',
|
||||
'*.exe',
|
||||
'*.gif',
|
||||
'*.jpeg',
|
||||
'*.jpg',
|
||||
'*.o',
|
||||
'*.obj',
|
||||
'*.out',
|
||||
'*.png',
|
||||
'*.pyc',
|
||||
'*.so',
|
||||
'*.zip',
|
||||
'*~',
|
||||
".git",
|
||||
".svn",
|
||||
"__pycache__",
|
||||
"**/tmp/**",
|
||||
"*.DS_Store",
|
||||
"*.dll",
|
||||
"*.egg-info",
|
||||
"*.exe",
|
||||
"*.gif",
|
||||
"*.jpeg",
|
||||
"*.jpg",
|
||||
"*.o",
|
||||
"*.obj",
|
||||
"*.out",
|
||||
"*.png",
|
||||
"*.pyc",
|
||||
"*.so",
|
||||
"*.zip",
|
||||
"*~",
|
||||
}
|
||||
o.wildignorecase = true -- ignore case when completing file names
|
||||
o.wildmode = 'longest:full' -- longest common prefix first, then wildmenu
|
||||
o.wildmode = "longest:full" -- longest common prefix first, then wildmenu
|
||||
|
||||
-- Window Splitting
|
||||
o.splitbelow = true -- :split below current window
|
||||
|
@ -127,16 +128,16 @@ M.setup = function()
|
|||
-- Folding
|
||||
o.foldenable = true -- enable folding
|
||||
o.foldlevelstart = 100 -- start with all folds open
|
||||
o.foldmethod = 'syntax' -- fold based on syntax by default
|
||||
o.foldmethod = "syntax" -- fold based on syntax by default
|
||||
o.foldnestmax = 10 -- limit nested folds to 10 levels
|
||||
|
||||
-- Options for diff mode
|
||||
o.diffopt = { -- better side-by-side diffs
|
||||
'filler', -- show filler lines (so text is vertically synced)
|
||||
'vertical', -- use vertical splits (files side-by-side)
|
||||
'closeoff', -- disable diff mode when one window is closed
|
||||
"filler", -- show filler lines (so text is vertically synced)
|
||||
"vertical", -- use vertical splits (files side-by-side)
|
||||
"closeoff", -- disable diff mode when one window is closed
|
||||
}
|
||||
end
|
||||
-- stylua: ignore end
|
||||
|
||||
return M
|
||||
|
||||
|
|
|
@ -18,11 +18,13 @@ end
|
|||
---@param direction string: one of 'h', 'j', 'k', or 'l'
|
||||
local is_last = function(direction)
|
||||
local current = vim.api.nvim_get_current_win()
|
||||
vim.cmd('wincmd ' .. direction)
|
||||
vim.cmd("wincmd " .. direction)
|
||||
local next = vim.api.nvim_get_current_win()
|
||||
|
||||
local is_last = current == next
|
||||
if not is_last then vim.cmd('wincmd p') end
|
||||
if not is_last then
|
||||
vim.cmd("wincmd p")
|
||||
end
|
||||
|
||||
return is_last
|
||||
end
|
||||
|
@ -31,26 +33,28 @@ end
|
|||
---@param dir string: one of 'h', 'j', 'k', or 'l'
|
||||
---@param size integer: how much to resize
|
||||
local resize = function(dir, size)
|
||||
if dir ~= 'h' and dir ~= 'j' and dir ~= 'k' and dir ~= 'l' then return end
|
||||
if dir ~= "h" and dir ~= "j" and dir ~= "k" and dir ~= "l" then
|
||||
return
|
||||
end
|
||||
|
||||
size = math.abs(size)
|
||||
local is_height = dir == 'j' or dir == 'k'
|
||||
local is_positive = dir == 'j' or dir == 'l'
|
||||
local is_height = dir == "j" or dir == "k"
|
||||
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
|
||||
|
||||
local delta = string.format('%s%d', is_positive and '+' or '-', size)
|
||||
local prefix = is_height and '' or 'vertical '
|
||||
vim.cmd(prefix .. 'resize ' .. delta .. '<cr>')
|
||||
local delta = string.format("%s%d", is_positive and "+" or "-", size)
|
||||
local prefix = is_height and "" or "vertical "
|
||||
vim.cmd(prefix .. "resize " .. delta .. "<cr>")
|
||||
end
|
||||
|
||||
---Resize current window upwards.
|
||||
---@param size integer: how much to resize
|
||||
M.resize_up = function(size)
|
||||
return function()
|
||||
resize('k', size)
|
||||
resize("k", size)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,7 +62,7 @@ end
|
|||
---@param size integer: how much to resize
|
||||
M.resize_down = function(size)
|
||||
return function()
|
||||
resize('j', size)
|
||||
resize("j", size)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -66,7 +70,7 @@ end
|
|||
---@param size integer: how much to resize
|
||||
M.resize_left = function(size)
|
||||
return function()
|
||||
resize('h', size)
|
||||
resize("h", size)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,35 +78,38 @@ end
|
|||
---@param size integer: how much to resize
|
||||
M.resize_right = function(size)
|
||||
return function()
|
||||
resize('l', size)
|
||||
resize("l", size)
|
||||
end
|
||||
end
|
||||
|
||||
---Toggle quickfix (or location) list.
|
||||
---@param qf string: 'c' for quickfix, 'l' for location list
|
||||
local toggle_list = function(qf)
|
||||
local l = qf == 'l' and 1 or 0
|
||||
local is_qf = function(win) return win.quickfix == 1 and win.loclist == l end
|
||||
local l = qf == "l" and 1 or 0
|
||||
local is_qf = function(win)
|
||||
return win.quickfix == 1 and win.loclist == l
|
||||
end
|
||||
local is_open = not vim.tbl_isempty(vim.tbl_filter(is_qf, vim.fn.getwininfo()))
|
||||
if is_open then
|
||||
vim.cmd(qf .. 'close')
|
||||
vim.cmd(qf .. "close")
|
||||
else
|
||||
local ok = pcall(function(c) vim.cmd(c) end, qf .. 'open')
|
||||
if not ok and qf == 'l' then
|
||||
vim.notify('No location list', vim.log.levels.WARN)
|
||||
local ok = pcall(function(c)
|
||||
vim.cmd(c)
|
||||
end, qf .. "open")
|
||||
if not ok and qf == "l" then
|
||||
vim.notify("No location list", vim.log.levels.WARN)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Toggle quickfix list.
|
||||
M.toggle_quickfix = function()
|
||||
toggle_list('c')
|
||||
toggle_list("c")
|
||||
end
|
||||
|
||||
---Toggle location list.
|
||||
M.toggle_loclist = function()
|
||||
toggle_list('l')
|
||||
toggle_list("l")
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue