1
0

feat: initial commit

This commit is contained in:
Rokas Puzonas 2021-10-29 16:09:55 +03:00
commit 48cebf1f8f
9 changed files with 220 additions and 0 deletions

13
init.lua Normal file
View File

@ -0,0 +1,13 @@
local g = vim.g
-- Allow loading */init.lua files
package.path = "./?/init.lua;"..package.path
-- Leader/local leader
g.mapleader = [[ ]]
g.maplocalleader = [[,]]
require("impatient")
require("plugins")

3
lua/config/fugitive.lua Normal file
View File

@ -0,0 +1,3 @@
local map = require 'utils.map'
map('n', '<leader>gg', ':G<cr>', { silent = true })

0
lua/options.lua Normal file
View File

75
lua/plugins.lua Normal file
View File

@ -0,0 +1,75 @@
local function usePlugins(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
-- Improve startup time when loading lua files.
-- Temporary solution before PR gets merges. https://github.com/neovim/neovim/pull/15436
use 'lewis6991/impatient.nvim'
-- Git integration
use { 'tpope/vim-fugitive', config = [[require 'config.fugitive']] }
end
-- Register custom commands for plugin manager
vim.cmd [[command! PackerInstall packadd packer.nvim | lua require('plugins').install()]]
vim.cmd [[command! PackerUpdate packadd packer.nvim | lua require('plugins').update()]]
vim.cmd [[command! PackerSync packadd packer.nvim | lua require('plugins').sync()]]
vim.cmd [[command! PackerClean packadd packer.nvim | lua require('plugins').clean()]]
vim.cmd [[command! PackerCompile packadd packer.nvim | lua require('plugins').compile()]]
-- Run "PackerCompile" whenever this file is updated
vim.cmd [[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]]
-- Bootstrap packer.nvim. If packer.nvim is not installed, install it.
local function bootstrap()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
local packer_bootstrap
if fn.empty(fn.glob(install_path)) > 0 then
return fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
end
local packer = nil
local function init()
-- Perform bootstrap
local packer_bootstrap = bootstrap()
-- Initialize packer
if packer == nil then
packer = require 'packer'
local util = require 'packer.util'
packer.init {
compile_path = util.join_paths(vim.fn.stdpath('config'), 'plugin', 'packer-compiled.lua'),
disable_commands = true
}
end
-- Reset plugins if already loaded
packer.reset()
-- Use plugins
usePlugins(packer.use, packer.use_rocks)
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end
local plugins = setmetatable({}, {
__index = function(_, key)
init()
return packer[key]
end,
})
return plugins

11
lua/utils/autocmd.lua Normal file
View File

@ -0,0 +1,11 @@
local cmd = vim.cmd
return function(group, cmds, clear)
clear = clear == nil and false or clear
if type(cmds) == 'string' then cmds = {cmds} end
cmd('augroup ' .. group)
if clear then cmd [[au!]] end
for _, c in ipairs(cmds) do cmd('autocmd ' .. c) end
cmd [[augroup END]]
end

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

@ -0,0 +1,6 @@
local path = ...
return {
map = require(... .. ".map"),
opt = require(... .. ".opt"),
autocmd = require(... .. ".autocmd"),
}

8
lua/utils/map.lua Normal file
View File

@ -0,0 +1,8 @@
local map_key = vim.api.nvim_set_keymap
return function(modes, lhs, rhs, opts)
opts = opts or {}
opts.noremap = opts.noremap == nil and true or opts.noremap
if type(modes) == 'string' then modes = {modes} end
for _, mode in ipairs(modes) do map_key(mode, lhs, rhs, opts) end
end

6
lua/utils/opt.lua Normal file
View File

@ -0,0 +1,6 @@
local o_s = vim.o
return function(o, v, scopes)
scopes = scopes or {o_s}
for _, s in ipairs(scopes) do s[o] = v end
end

View File

@ -0,0 +1,98 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
_G._packer = _G._packer or {}
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/puzonas/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s))
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["impatient.nvim"] = {
loaded = true,
path = "/home/puzonas/.local/share/nvim/site/pack/packer/start/impatient.nvim"
},
["packer.nvim"] = {
loaded = true,
path = "/home/puzonas/.local/share/nvim/site/pack/packer/start/packer.nvim"
},
["vim-fugitive"] = {
config = { "require 'config.fugitive'" },
loaded = true,
path = "/home/puzonas/.local/share/nvim/site/pack/packer/start/vim-fugitive"
}
}
time([[Defining packer_plugins]], false)
-- Config for: vim-fugitive
time([[Config for vim-fugitive]], true)
require 'config.fugitive'
time([[Config for vim-fugitive]], false)
if should_profile then save_profiles() end
end)
if not no_errors then
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end