1
Fork 0

Removed the need for my own augroup helper

This commit is contained in:
Matei Adriel 2022-08-24 14:54:19 +03:00
parent 7c77d3a8dd
commit c610d1ce1a
8 changed files with 12 additions and 113 deletions

View file

@ -1 +1,2 @@
vim.cmd("syntax hkf")
vim.api.nvim_buf_set_option(0, "commentstring", "-- %s")

View file

@ -1,14 +0,0 @@
local M = {}
function M.augroup(name, inside)
vim.cmd('augroup ' .. name)
vim.cmd('autocmd!')
inside()
vim.cmd('augroup END')
end
function M.autocmd(event, glob, action)
vim.cmd('autocmd ' .. event .. ' ' .. glob .. ' ' .. action)
end
return M

View file

@ -1,9 +1,9 @@
local M = {}
function M.update()
require("my.helpers").saveCursor(function()
vim.cmd(":%!update-nix-fetchgit")
end)
require("my.helpers").saveCursor(function()
vim.cmd(":%!update-nix-fetchgit")
end)
end
return M

View file

@ -1,15 +1,7 @@
local M = {}
function M.setup()
vim.o.foldmethod = "marker"
-- vim.cmd([[
-- augroup remember_folds
-- autocmd!
-- autocmd BufWinLeave *.* if &ft !=# 'help' | mkview | endif
-- autocmd BufWinEnter *.* if &ft !=# 'help' | silent! loadview | endif
-- augroup END
-- ]])
vim.o.foldmethod = "marker"
end
return M

View file

@ -1,26 +0,0 @@
local A = require("my.helpers.augroup")
local M = {}
local extraCommentStrings = { lean = "/- %s -/", bkf = "-- %s" }
-- Update comments for certain languages
function M.setCommentString(extension, commentString)
A.augroup('set-commentstring-' .. extension, function()
local action =
':lua vim.api.nvim_buf_set_option(0, "commentstring", "' ..
commentString .. '")'
A.autocmd('BufEnter', '*.' .. extension, action)
A.autocmd('BufFilePost', '*.' .. extension, action)
end)
end
function M.setup()
require('nvim_comment').setup()
for lang, commentString in pairs(extraCommentStrings) do
M.setCommentString(lang, commentString)
end
end
return M

View file

@ -4,6 +4,7 @@ local M = {}
function M.setup()
require('nvim-autopairs').setup()
require "gitlinker".setup()
require('nvim_comment').setup()
vscode.unless(function()
require("presence"):setup({})
@ -20,7 +21,6 @@ function M.setup()
end)
require("my.plugins.neogit").setup()
require("my.plugins.comment").setup()
require("my.plugins.telescope").setup()
-- require("my.plugins.idris").setup()

View file

@ -1,53 +0,0 @@
local A = require("my.helpers.augroup")
local arpeggio = require("my.plugins.arpeggio")
local M = {}
local extraBrackets = {
lean = { { "", "" } }, -- lean
all = {
-- {"(", ")"}, {"[", "]"}, {"'", "'"}, {'"', '"'}, {"{", "}"}, {"`", "`"}
} -- more general stuff
}
function M.createBracketCommand(lhs, rhs, isGlobal, opts)
local suffix = ""
if isGlobal then suffix = "!" end
return ":Brackets" .. suffix .. " " .. lhs .. " " .. rhs .. " " ..
(opts or "")
end
function M.createBracket(lhs, rhs, isGlobal, opts)
vim.cmd(M.createBracketCommand(lhs, rhs, isGlobal, opts))
end
function M.setup()
if arpeggio == nil then return end
vim.g.marker_define_jump_mappings = 0 -- disable automatic binding of marker jumping (conflicts with tmux-vim-navigator)
arpeggio.chord("nv", "sj", '<Plug>MarkersJumpF')
arpeggio.chord("nv", "sk", '<Plug>MarkersJumpB')
arpeggio.chord("nv", "mi", '<Plug>MarkersMark')
arpeggio.chord("nv", "ml", '<Plug>MarkersCloseAllAndJumpToLast')
arpeggio.chord("nv", "mo", '<Plug>MarkersJumpOutside')
for key, brackets in pairs(extraBrackets) do
A.augroup('custom-brackets' .. key, function()
for _, v in ipairs(brackets) do
local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "")
local glob = '*.' .. key
if key == "all" then
-- The all key just matches everything
glob = "*"
end
A.autocmd('BufEnter', glob, action)
end
end)
end
end
return M

View file

@ -1,7 +1,6 @@
local M = {}
local function map(buf, mode, lhs, rhs, opts)
local options = { noremap = true, silent = true }
if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options)
@ -11,14 +10,14 @@ function M.on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
if client.server_capabilities.documentFormattingProvider then
print("Initializing formatter...")
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
augroup END
]])
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("LspFormatting", {}),
callback = vim.lsp.buf.formatting_sync
})
end
print("Setting up keybinds...")