diff --git a/lua/maps.lua b/lua/maps.lua index e69de29..e0af2aa 100644 --- a/lua/maps.lua +++ b/lua/maps.lua @@ -0,0 +1,28 @@ +local function map(mode, lhs, rhs, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +vim.g.mapleader = "," +-- Toggle Goyo +map('n', '', ':Goyo', {noremap = false}) +-- Open and move to resized terminal +map('n', 't', 'sj :terminal:res 5i', {noremap = false}) +-- Enter normal mode in terminal +map('t', '', '') +-- Clear highlight +map('n', '', 'noh') +-- Move to window in any mode +map('t', 'ª', 'h') +map('t', 'º', 'j') +map('t', '∆', 'k') +map('t', '@', 'l') +map('i', 'ª', 'h') +map('i', 'º', 'j') +map('i', '∆', 'k') +map('i', '@', 'l') +map('n', 'ª', 'h') +map('n', 'º', 'j') +map('n', '∆', 'k') +map('n', '@', 'l') diff --git a/lua/settings.lua b/lua/settings.lua index b4c652b..12fb2cd 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -1,37 +1,40 @@ -- settings.lua -local o = vim.o -local wo = vim.wo -local bo = vim.bo -local g = vim.g local cmd = vim.cmd +local scopes = {o = vim.o, bo = vim.bo, wo = vim.wo} + +local function opt(scope, key, value) + scopes[scope][key] = value + if scope ~= 'o' then scopes['o'][key] = value end +end + ---- Misc Options -- global options -o.swapfile = true -o.dir = '/tmp' -o.smartcase = true -o.laststatus = 2 -o.hlsearch = true -o.incsearch = true -o.ignorecase = true -o.scrolloff = 12 -o.mouse = 'a' +opt('o', 'swapfile', true) +opt('o', 'dir', '/tmp') +opt('o', 'smartcase', true) +opt('o', 'laststatus', 2) +opt('o', 'hlsearch', true) +opt('o', 'incsearch', true) +opt('o', 'ignorecase', true) +opt('o', 'scrolloff', 12) +opt('o', 'mouse', 'a') -- window-local options -wo.number = true -wo.wrap = false +opt('wo', 'number', true) +opt('wo', 'wrap', false) -- buffer-local options -bo.shiftwidth = 4 -bo.tabstop = 4 -bo.softtabstop = 4 -bo.expandtab = true -bo.autoindent = true +opt('bo', 'shiftwidth', 4) +opt('bo', 'tabstop', 4) +opt('bo', 'softtabstop', 4) +opt('bo', 'expandtab', true) +opt('bo', 'autoindent', true) ---- Theme -- Font -o.guifont = 'Source Code Pro for Powerline' +opt('o', 'guifont', 'Source Code Pro for Powerline') -- Statusline local lualine = require('lualine') @@ -43,9 +46,9 @@ bufferline.setup() local function ColorDarcula() lualine.options.theme = 'onedark' - g.limelight_conceal_ctermfg = 'DarkGray' + limelight_conceal_ctermfg = 'DarkGray' cmd 'colorscheme darcula' end -bo.syntax = 'on' +opt('bo', 'syntax', 'on') ColorDarcula()