Added Code Folding and Terminal Toggle
This commit is contained in:
95
init.lua
95
init.lua
@@ -1,4 +1,10 @@
|
|||||||
-- Editor Settings
|
-- Source configs with dependencies {{{
|
||||||
|
--for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath('config')..'/lua-heavy', [[v:val =~ '\.lua$']])) do
|
||||||
|
-- require(file:gsub('%.lua$', ''))
|
||||||
|
--end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- General Editor Settings {{{
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
vim.opt.cursorline = true
|
vim.opt.cursorline = true
|
||||||
@@ -11,7 +17,6 @@ vim.opt.path:append '**'
|
|||||||
vim.opt.path:append '.'
|
vim.opt.path:append '.'
|
||||||
vim.opt.wildmenu = true
|
vim.opt.wildmenu = true
|
||||||
vim.opt.wrap = false
|
vim.opt.wrap = false
|
||||||
vim.opt.foldenable = false
|
|
||||||
vim.opt.clipboard = 'unnamedplus'
|
vim.opt.clipboard = 'unnamedplus'
|
||||||
vim.opt.undofile = true
|
vim.opt.undofile = true
|
||||||
vim.opt.ignorecase = true
|
vim.opt.ignorecase = true
|
||||||
@@ -19,49 +24,77 @@ vim.opt.smartcase = true
|
|||||||
vim.opt.updatetime = 250
|
vim.opt.updatetime = 250
|
||||||
vim.opt.timeoutlen = 300
|
vim.opt.timeoutlen = 300
|
||||||
vim.opt.inccommand = 'split'
|
vim.opt.inccommand = 'split'
|
||||||
|
vim.opt.foldmethod = 'marker'
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Setup (Disable) Netrw {{{
|
||||||
|
vim.g.loaded_netrw = 1
|
||||||
-- Setup Netrw
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
--[[
|
||||||
vim.g.netrw_banner = 0
|
vim.g.netrw_banner = 0
|
||||||
vim.g.netrw_sort_sequence = '[\\/]$'
|
vim.g.netrw_sort_sequence = '[\\/]$'
|
||||||
vim.g.netrw_sort_options = 'i'
|
vim.g.netrw_sort_options = 'i'
|
||||||
vim.g.netrw_silent = 1
|
vim.g.netrw_silent = 1
|
||||||
--[[
|
|
||||||
vim.g.netrw_browse_split = 4
|
|
||||||
vim.g.netrw_altv = 1
|
|
||||||
vim.g.netrw_preview = 1
|
|
||||||
vim.g.netrw_winsize = 20
|
|
||||||
local mygroup = vim.api.nvim_create_augroup('loading_netrwPlugin', {clear = true})
|
|
||||||
vim.api.nvim_create_autocmd({'VimEnter'}, {
|
|
||||||
pattern = {'*'},
|
|
||||||
command = ':silent! Vexplore',
|
|
||||||
group = NetrwInit
|
|
||||||
})
|
|
||||||
]]
|
]]
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- WriteSudo and ReadSudo hacks {{{
|
||||||
|
|
||||||
-- Added autocmd for automatic insertmode in Terminal Mode
|
|
||||||
vim.api.nvim_create_autocmd({ 'TermOpen' }, {
|
|
||||||
pattern = { 'term://*' },
|
|
||||||
command = 'startinsert',
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- WriteSudo and ReadSudo hacks
|
|
||||||
vim.api.nvim_create_user_command('WriteSudo', 'w !sudo tee %', {})
|
vim.api.nvim_create_user_command('WriteSudo', 'w !sudo tee %', {})
|
||||||
vim.api.nvim_create_user_command('ReadSudo', function(opts)
|
vim.api.nvim_create_user_command('ReadSudo', function(opts)
|
||||||
vim.cmd('r !sudo cat ' .. opts['args'])
|
vim.cmd('r !sudo cat ' .. opts['args'])
|
||||||
end, { nargs = 1 })
|
end, { nargs = 1 })
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Statusbar {{{
|
||||||
|
|
||||||
-- Statusbar
|
|
||||||
vim.opt.statusline = ' #%n %f %h%w%m%r %= %y %l:%c %p%% '
|
vim.opt.statusline = ' #%n %f %h%w%m%r %= %y %l:%c %p%% '
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Toggle Terminal Script {{{
|
||||||
|
local te_buf = nil
|
||||||
|
local te_win_id = nil
|
||||||
|
|
||||||
|
local v = vim
|
||||||
|
local fun = v.fn
|
||||||
|
local cmd = v.api.nvim_command
|
||||||
|
local gotoid = fun.win_gotoid
|
||||||
|
local getid = fun.win_getid
|
||||||
|
|
||||||
-- Keymaps
|
local function openTerminal()
|
||||||
|
if fun.bufexists(te_buf) ~= 1 then
|
||||||
|
cmd("au TermOpen * setlocal nonumber norelativenumber signcolumn=no")
|
||||||
|
cmd("sp | winc J | res 10 | te")
|
||||||
|
te_win_id = getid()
|
||||||
|
te_buf = fun.bufnr('%')
|
||||||
|
elseif gotoid(te_win_id) ~= 1 then
|
||||||
|
cmd("sb " .. te_buf .. "| winc J | res 10")
|
||||||
|
te_win_id = getid()
|
||||||
|
end
|
||||||
|
cmd("startinsert")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function hideTerminal()
|
||||||
|
if gotoid(te_win_id) == 1 then
|
||||||
|
cmd("hide")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ToggleTerminal()
|
||||||
|
if gotoid(te_win_id) == 1 then
|
||||||
|
hideTerminal()
|
||||||
|
else
|
||||||
|
openTerminal()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Automatic insertmode in Terminal Mode {{{
|
||||||
|
vim.api.nvim_create_autocmd({ 'TermOpen' }, {
|
||||||
|
pattern = { 'term://*' },
|
||||||
|
command = 'startinsert',
|
||||||
|
})
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Keymaps {{{
|
||||||
vim.api.nvim_set_keymap('n', '<leader>f', ':find ', { noremap = true, silent = true })
|
vim.api.nvim_set_keymap('n', '<leader>f', ':find ', { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>t', ToggleTerminal)
|
||||||
|
-- }}}
|
||||||
|
|||||||
Reference in New Issue
Block a user