Move from vim script to lua init file

This commit is contained in:
2021-09-07 21:08:02 +02:00
parent 2870ce61ee
commit f38e21f648
5 changed files with 135 additions and 305 deletions

16
lua/keymappings.lua Normal file
View File

@ -0,0 +1,16 @@
local utils = require('utils')
vim.g.mapleader = ','
-- Paste from clipboard
utils.map('n', '<leader>p', '"+p')
utils.map('n', '<leader>P', '"+P')
utils.map('v', '<leader>p', '"+p')
utils.map('v', '<leader>P', '"+P')
-- Yank to clipboard
utils.map('v', '<leader>y', '"+y')
utils.map('n', '<leader>Y', '"+yg_')
utils.map('n', '<leader>y', '"+y')
utils.map('n', '<leader>yy', '"+yy')
-- Tabs and Split
utils.map('n', 'F2', ':tabnew .<CR>')

16
lua/plugins.lua Normal file
View File

@ -0,0 +1,16 @@
return require('packer').startup(function()
-- Packer can manage itself as an optional plugin
use {'wbthomason/packer.nvim', opt = true}
use {'neovim/nvim-lspconfig'}
use {'nvim-treesitter/nvim-treesitter'}
use {
'nvim-telescope/telescope.nvim',
requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}
}
use {'sainnhe/gruvbox-material'}
use {'lukas-reineke/indent-blankline.nvim'}
use {'nvim-lua/plenary.nvim'}
use {'lewis6991/gitsigns.nvim'}
use {'kosayoda/nvim-lightbulb'}
end)

16
lua/utils/init.lua Normal file
View File

@ -0,0 +1,16 @@
local utils = { }
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
function utils.opt(scope, key, value)
scopes[scope][key] = value
if scope ~= 'o' then scopes['o'][key] = value end
end
function utils.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
return utils