Skip to content

Instantly share code, notes, and snippets.

@olimorris
Created March 8, 2021 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olimorris/f874b574fec2d1f48514d45d5ab0d18b to your computer and use it in GitHub Desktop.
Save olimorris/f874b574fec2d1f48514d45d5ab0d18b to your computer and use it in GitHub Desktop.
----------------------------- Terminal Toggle ------------------------------ {{{
-- Uses the awesome kassio/neoterm plugin
function TermToggle(height)
-- Always open the terminal in a horizontal pane at the bottom
g.neoterm_default_mod = 'botright'
-- Set the height of the terminal
g.neoterm_size = height
cmd ':Ttoggle'
end
utils.map('n', '<C-x>', ':call v:lua.TermToggle(8)<cr>', {silent = true})
utils.map('i', '<C-x>', '<esc>:call v:lua.TermToggle(8)<cr>', {silent = true})
utils.map('t', '<C-x>', '<C-\\><C-n>:call v:lua.TermToggle(8)<cr>', {silent = true})
---------------------------------------------------------------------------- }}}
------------------------------- Minimal Mode ------------------------------- {{{
minimal_mode = 0
function ToggleMinimal()
if minimal_mode == 0 then
minimal_mode = 1
w.number = false
w.colorcolumn = '0'
w.signcolumn = 'no'
o.laststatus = 0
o.showtabline = 0
cmd 'ScrollViewDisable'
else
minimal_mode = 0
w.number = true
w.colorcolumn = '80'
w.signcolumn = 'yes'
o.laststatus = 2
o.showtabline = 2
cmd 'ScrollViewEnable'
end
end
utils.map('n', '<S-m>', ':call v:lua.ToggleMinimal()<cr>', {silent = true})
---------------------------------------------------------------------------- }}}
------------------------------- Theme Toggle ------------------------------- {{{
function SetTheme(mode)
vim.api.nvim_set_option('background', mode)
theme = 'colorscheme '..colorschemes[mode]
cmd(theme)
end
function ThemeToggle()
if vim.api.nvim_get_option('background') == 'dark' then
mode = 'light'
else
mode = 'dark'
end
return pcall(SetTheme, mode)
end
utils.map('n', '<leader>1', ':call v:lua.ThemeToggle()<cr>', {silent = true})
---------------------------------------------------------------------------- }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment