Compare commits
4 Commits
33c40f9b4d
...
71c7e986a5
| Author | SHA1 | Date | |
|---|---|---|---|
| 71c7e986a5 | |||
| b24b91367c | |||
| 85c5bad010 | |||
| e80a93bc0d |
100
init.lua
100
init.lua
@@ -1,4 +1,12 @@
|
|||||||
-- Editor Settings
|
-- Set Language {{{
|
||||||
|
vim.api.nvim_exec2('language POSIX', {})
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Source plugins if they exist {{{
|
||||||
|
pcall(require, 'plugins')
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- 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,57 +19,83 @@ 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.ignorecase = true
|
vim.opt.ignorecase = true
|
||||||
vim.opt.smartcase = true
|
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 term_buf = nil
|
||||||
|
local term_winid = nil
|
||||||
|
|
||||||
|
local function openTerminal()
|
||||||
|
if vim.fn.bufexists(term_buf) ~= 1 then
|
||||||
|
vim.api.nvim_command("autocmd TermOpen * setlocal nonumber norelativenumber signcolumn=no")
|
||||||
|
vim.api.nvim_command("split | wincmd J | resize 10 | term")
|
||||||
|
term_winid = vim.fn.win_getid()
|
||||||
|
term_buf = vim.fn.bufnr('%')
|
||||||
|
elseif vim.fn.win_gotoid(term_winid) ~= 1 then
|
||||||
|
vim.api.nvim_command("sbuffer " .. term_buf .. "| wincmd J | resize 10")
|
||||||
|
term_winid = vim.fn.win_getid()
|
||||||
|
end
|
||||||
|
vim.api.nvim_command("startinsert")
|
||||||
|
end
|
||||||
|
|
||||||
-- Keymaps
|
local function hideTerminal()
|
||||||
vim.api.nvim_set_keymap('n', '<leader>f', ':find ', { noremap = true, silent = true })
|
if vim.fn.win_gotoid(term_winid) == 1 then
|
||||||
|
vim.api.nvim_command("hide")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ToggleTerminal()
|
||||||
|
if vim.fn.win_gotoid(term_winid) == 1 then
|
||||||
|
hideTerminal()
|
||||||
|
else
|
||||||
|
openTerminal()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Automatic insertmode in Terminal Mode {{{
|
||||||
|
vim.api.nvim_create_autocmd({ 'TermOpen' }, {
|
||||||
|
pattern = { 'term://*' },
|
||||||
|
command = 'startinsert',
|
||||||
|
})
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Keymaps {{{
|
||||||
|
vim.keymap.set('n', '<F6>', ':b#<CR>', { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', '<F7>', ':bprevious<CR>', { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', '<F8>', ':bnext<CR>', { noremap = true, silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>f', ':find ', { noremap = true })
|
||||||
|
vim.keymap.set('n', '<leader>t', ToggleTerminal)
|
||||||
|
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>')
|
||||||
|
vim.keymap.set('n', 'x', '"_x')
|
||||||
|
vim.keymap.set('n', '<leader>b', ':buffers<CR>:buffer ', { noremap = true, silent = true })
|
||||||
|
-- }}}
|
||||||
|
|||||||
Reference in New Issue
Block a user