Move files out of their respective fs structure into program dirs in root and symlink dotfils using HM.
This commit is contained in:
parent
10bab010b7
commit
fb2adb4547
72 changed files with 9 additions and 0 deletions
44
nvim/lua/format_handler.lua
Normal file
44
nvim/lua/format_handler.lua
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
local utils = require("utils")
|
||||
local M = {}
|
||||
M.format_on_save = true
|
||||
|
||||
function M.format(force)
|
||||
local do_force = force or false
|
||||
if M.format_on_save or do_force then
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
end
|
||||
|
||||
function M.format_enable()
|
||||
M.format_on_save = true
|
||||
end
|
||||
|
||||
function M.format_disable()
|
||||
M.format_on_save = false
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
local user_commands = {
|
||||
{ "FormatEnable", "lua require('format_handler').format_enable()" },
|
||||
{ "FormatDisable", "lua require('format_handler').format_disable()" },
|
||||
}
|
||||
for _, cmd in ipairs(user_commands) do
|
||||
vim.api.nvim_command("command! " .. cmd[1] .. " " .. cmd[2])
|
||||
end
|
||||
|
||||
utils.add_keymaps({
|
||||
n = {
|
||||
["<leader>ff"] = {
|
||||
cmd = function() M.format(true) end
|
||||
},
|
||||
["<leader>fe"] = {
|
||||
cmd = M.format_enable,
|
||||
},
|
||||
["<leader>fd"] = {
|
||||
cmd = M.format_disable,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue