build core, basic and go variants and add template
This commit is contained in:
32
basic/nvim/init/00-basic.lua
Normal file
32
basic/nvim/init/00-basic.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local pack = require('pack')
|
||||
|
||||
-- tmux integration
|
||||
pack 'vim-tmux-navigator'
|
||||
pack 'vimux'
|
||||
|
||||
-- File tree navigation
|
||||
pack 'nvim-web-devicons'
|
||||
pack 'nvim-tree.lua'
|
||||
pack 'ctrlp.vim'
|
||||
|
||||
-- Language servers and snippets
|
||||
pack 'nvim-lspconfig'
|
||||
pack 'LuaSnip'
|
||||
|
||||
-- Completion
|
||||
pack 'cmp-buffer'
|
||||
pack 'cmp-path'
|
||||
pack 'cmp-cmdline'
|
||||
pack 'cmp-nvim-lua'
|
||||
pack 'cmp-nvim-lsp'
|
||||
pack 'cmp_luasnip'
|
||||
pack 'nvim-cmp'
|
||||
|
||||
-- Editing
|
||||
pack 'auto-pairs'
|
||||
pack 'vim-surround'
|
||||
pack 'vim-repeat'
|
||||
|
||||
-- Visuals
|
||||
pack 'vim-buftabline'
|
||||
pack 'nvim-juliana'
|
||||
9
basic/nvim/lua/pack.lua
Normal file
9
basic/nvim/lua/pack.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
local conf_path = 'plugconf/%s.lua'
|
||||
|
||||
function pack(name)
|
||||
vim.cmd('packadd! ' .. name)
|
||||
name = name:gsub('^n?vim%-', ''):gsub('%..*$', '')
|
||||
vim.cmd.runtime(conf_path:format(name))
|
||||
end
|
||||
|
||||
return pack
|
||||
25
basic/nvim/luasnippets/all.lua
Normal file
25
basic/nvim/luasnippets/all.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
return {
|
||||
parse(
|
||||
{ trig = 'lorem', name = 'Lorem ipsum sentence' },
|
||||
table.concat({
|
||||
'Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint',
|
||||
'cillum sint consectetur cupidatat.',
|
||||
}, " ")
|
||||
),
|
||||
parse(
|
||||
{ trig = 'loremipsum', name = "Lorem ipsum paragraph" },
|
||||
table.concat({
|
||||
'Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit',
|
||||
'enim labore culpa sint ad nisi Lorem pariatur mollit ex esse',
|
||||
'exercitation amet. Nisi anim cupidatat excepteur officia.',
|
||||
'Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate',
|
||||
'voluptate dolor minim nulla est proident. Nostrud officia pariatur ut',
|
||||
'officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit',
|
||||
'commodo officia dolor Lorem duis laboris cupidatat officia voluptate.',
|
||||
'Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis',
|
||||
'officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis',
|
||||
'sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea',
|
||||
'consectetur et est culpa et culpa duis.',
|
||||
}, ' ')
|
||||
),
|
||||
}
|
||||
13
basic/nvim/plugconf/LuaSnip.lua
Normal file
13
basic/nvim/plugconf/LuaSnip.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
local luasnip = require 'luasnip'
|
||||
local loader = require 'luasnip.loaders.from_lua'
|
||||
|
||||
luasnip.setup {
|
||||
-- Enable live updates
|
||||
update_events = { 'TextChanged', 'TextChangedI' },
|
||||
|
||||
-- Stop jumping when deleted
|
||||
delete_check_events = { 'TextChanged' },
|
||||
}
|
||||
|
||||
-- Automatically load lua snippets
|
||||
loader.lazy_load()
|
||||
4
basic/nvim/plugconf/auto-pairs.lua
Normal file
4
basic/nvim/plugconf/auto-pairs.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
-- Replace <c-b> mapping
|
||||
vim.keymap.set('i', '<c-b>', '{', { remap = true })
|
||||
vim.keymap.del('i', '<c-b> ')
|
||||
vim.keymap.del('i', '<c-b><cr>')
|
||||
6
basic/nvim/plugconf/cmp-nvim-lsp.lua
Normal file
6
basic/nvim/plugconf/cmp-nvim-lsp.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local lspconfig = require 'lspconfig'
|
||||
local cmp_nvim = require 'cmp_nvim_lsp'
|
||||
|
||||
-- Set default capabilities
|
||||
local capabilities = cmp_nvim.default_capabilities()
|
||||
lspconfig.util.default_config.capabilities = capabilities
|
||||
94
basic/nvim/plugconf/cmp.lua
Normal file
94
basic/nvim/plugconf/cmp.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
local cmp = require 'cmp'
|
||||
local context = require 'cmp.config.context'
|
||||
local luasnip = require 'luasnip'
|
||||
|
||||
vim.o.completeopt = nil
|
||||
|
||||
-- General setup
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args) luasnip.lsp_expand(args.body) end,
|
||||
},
|
||||
window = {
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
formatting = {
|
||||
fields = { 'menu', 'abbr', 'kind' },
|
||||
format = function(entry, item)
|
||||
item.menu = ({
|
||||
nvim_lsp = 'λ',
|
||||
luasnip = '⋗',
|
||||
buffer = 'Ω',
|
||||
path = '🖫',
|
||||
})[entry.source.name]
|
||||
return item
|
||||
end,
|
||||
},
|
||||
preselect = cmp.PreselectMode.None,
|
||||
mapping = {
|
||||
-- Confirm, jump or select with tab
|
||||
['<tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.get_selected_entry() then
|
||||
cmp.confirm()
|
||||
elseif luasnip.jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
elseif luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
elseif cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
-- Jump back with shift tab
|
||||
['<s-tab>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
-- Navigate options with ctrl n and ctrl p
|
||||
['<c-n>'] = cmp.mapping(function(fallback)
|
||||
if not cmp.visible() then
|
||||
cmp.complete()
|
||||
else
|
||||
cmp.select_next_item()
|
||||
end
|
||||
end),
|
||||
['<c-p>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then cmp.select_prev_item() else fallback() end
|
||||
end),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'nvim_lua' },
|
||||
}, {
|
||||
{ name = 'buffer', keyword_length = 5 },
|
||||
{ name = 'path' },
|
||||
}),
|
||||
completion = {
|
||||
keyword_length = 3
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
-- Disable in comments
|
||||
enabled = function()
|
||||
return not context.in_syntax_group('Comment')
|
||||
end,
|
||||
}
|
||||
|
||||
-- Command line setup
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
},{
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
completion = {
|
||||
keyword_length = 2
|
||||
},
|
||||
})
|
||||
5
basic/nvim/plugconf/ctrlp.lua
Normal file
5
basic/nvim/plugconf/ctrlp.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
-- Ctrlp
|
||||
vim.g.ctrlp_open_multiple_files = '1r'
|
||||
|
||||
-- Keyboard shortcuts
|
||||
vim.g.ctrlp_map = '<c-j>'
|
||||
5
basic/nvim/plugconf/juliana.lua
Normal file
5
basic/nvim/plugconf/juliana.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
local juliana = require 'nvim-juliana'
|
||||
|
||||
-- Set color scheme
|
||||
juliana.setup { colors = { fg4 = '#596875' } }
|
||||
vim.cmd.colorscheme('juliana')
|
||||
12
basic/nvim/plugconf/lspconfig.lua
Normal file
12
basic/nvim/plugconf/lspconfig.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Set keymaps
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'cr', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts)
|
||||
end,
|
||||
})
|
||||
9
basic/nvim/plugconf/tmux-navigator.lua
Normal file
9
basic/nvim/plugconf/tmux-navigator.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Disable wrapping
|
||||
vim.g.tmux_navigator_no_wrap = 1
|
||||
|
||||
-- Keyboard shortcuts
|
||||
vim.g.tmux_navigator_no_mappings = 1
|
||||
vim.keymap.set('n', '<m-h>', vim.cmd.TmuxNavigateLeft, { silent = true })
|
||||
vim.keymap.set('n', '<m-j>', vim.cmd.TmuxNavigateDown, { silent = true })
|
||||
vim.keymap.set('n', '<m-k>', vim.cmd.TmuxNavigateUp, { silent = true })
|
||||
vim.keymap.set('n', '<m-l>', vim.cmd.TmuxNavigateRight, { silent = true })
|
||||
106
basic/nvim/plugconf/tree.lua
Normal file
106
basic/nvim/plugconf/tree.lua
Normal file
@@ -0,0 +1,106 @@
|
||||
local tree = require 'nvim-tree'
|
||||
|
||||
-- Disable NetRw
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
-- Keyboard shortcuts
|
||||
vim.keymap.set('n', 'U', vim.cmd.NvimTreeToggle, { silent = true })
|
||||
|
||||
-- Configure Nvim Tree
|
||||
tree.setup {
|
||||
sync_root_with_cwd = true,
|
||||
update_focused_file = { enable = true },
|
||||
git = { ignore = false },
|
||||
renderer = {
|
||||
highlight_git = true,
|
||||
highlight_opened_files = "icon",
|
||||
root_folder_label = ":~:s?$?",
|
||||
},
|
||||
on_attach = function(buf)
|
||||
-- Mapping helpers
|
||||
local api = require 'nvim-tree.api'
|
||||
local function opts(desc) return {
|
||||
desc = 'nvim-tree: ' .. desc, buffer = buf,
|
||||
noremap = true, silent = true, nowait = true,
|
||||
} end
|
||||
|
||||
-- Directories
|
||||
vim.keymap.set('n', 'C', api.tree.change_root_to_node, opts('Change Directory'))
|
||||
vim.keymap.set('n', '-', api.tree.change_root_to_parent, opts('Up'))
|
||||
vim.keymap.set('n', 'P', api.node.navigate.parent, opts('Parent Directory'))
|
||||
|
||||
-- Open
|
||||
vim.keymap.set('n', '<cr>', api.node.open.edit, opts('Open: Toggle'))
|
||||
vim.keymap.set('n', '<space>', api.node.open.edit, opts('Open: Toggle'))
|
||||
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split'))
|
||||
vim.keymap.set('n', 's', api.node.open.horizontal, opts('Open: Horizontal Split'))
|
||||
vim.keymap.set('n', '<Tab>', api.node.open.preview, opts('Open: Preview'))
|
||||
vim.keymap.set('n', 'i', api.node.show_info_popup, opts('Info'))
|
||||
|
||||
-- File operations
|
||||
vim.keymap.set('n', 'r', api.fs.rename_sub, opts('Rename'))
|
||||
vim.keymap.set('n', 'R', api.fs.rename_basename, opts('Rename: Basename'))
|
||||
vim.keymap.set('n', 'a', api.fs.create, opts('Create'))
|
||||
vim.keymap.set('n', 'c', api.fs.copy.node, opts('Copy'))
|
||||
vim.keymap.set('n', 'x', api.fs.cut, opts('Cut'))
|
||||
vim.keymap.set('n', 'p', api.fs.paste, opts('Paste'))
|
||||
vim.keymap.set('n', 'd', api.fs.remove, opts('Delete'))
|
||||
vim.keymap.set('n', '.', api.node.run.cmd, opts('Run Command'))
|
||||
|
||||
-- Path copying
|
||||
vim.keymap.set('n', 'y', api.fs.copy.relative_path, opts('Copy Relative Path'))
|
||||
vim.keymap.set('n', 'Y', api.fs.copy.absolute_path, opts('Copy Absolute Path'))
|
||||
|
||||
-- Navigation
|
||||
vim.keymap.set('n', 'q', api.tree.close, opts('Close'))
|
||||
vim.keymap.set('n', '/', api.tree.search_node, opts('Search'))
|
||||
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
|
||||
|
||||
-- Filtering
|
||||
vim.keymap.set('n', 'f', api.live_filter.start, opts('Filter'))
|
||||
vim.keymap.set('n', 'F', api.live_filter.clear, opts('Clean Filter'))
|
||||
vim.keymap.set('n', 'H', api.tree.toggle_hidden_filter, opts('Toggle Dotfiles'))
|
||||
vim.keymap.set('n', 'T', api.tree.toggle_git_clean_filter, opts('Toggle Git Clean'))
|
||||
vim.keymap.set('n', 'Z', api.tree.collapse_all, opts('Collapse'))
|
||||
vim.keymap.set('n', 'z', api.tree.expand_all, opts('Expand All'))
|
||||
|
||||
-- Bookmarks
|
||||
vim.keymap.set('n', 'm', api.marks.toggle, opts('Toggle Bookmark'))
|
||||
vim.keymap.set('n', 'M', api.marks.bulk.move, opts('Move Bookmarked'))
|
||||
|
||||
-- Custom open and close
|
||||
vim.keymap.set('n', 'l', function()
|
||||
local node = api.tree.get_node_under_cursor()
|
||||
if node.type == 'directory' then
|
||||
if not node.open then api.node.open.edit() end
|
||||
else
|
||||
api.node.open.edit()
|
||||
end
|
||||
end, opts('Open'))
|
||||
|
||||
vim.keymap.set('n', 'h', function()
|
||||
local node = api.tree.get_node_under_cursor()
|
||||
if node.type == 'directory' then
|
||||
if node.open then api.node.open.edit() end
|
||||
else
|
||||
local path = node.absolute_path
|
||||
if vim.fn.buflisted(path) == 1 then
|
||||
if vim.fn.getbufinfo(path)[1].changed == 0 then
|
||||
vim.cmd.bdelete(path)
|
||||
else
|
||||
vim.notify('Buffer has unsaved changes', vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
end
|
||||
end, opts('Close'))
|
||||
|
||||
vim.keymap.set('n', 'o', function()
|
||||
local node = api.tree.get_node_under_cursor()
|
||||
if node.type == 'file' then
|
||||
api.node.open.edit()
|
||||
api.tree.focus()
|
||||
end
|
||||
end, opts('Open: Keep Focus'))
|
||||
end
|
||||
}
|
||||
10
basic/nvim/plugconf/vimux.lua
Normal file
10
basic/nvim/plugconf/vimux.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Keyboard shortcuts
|
||||
if vim.env.TMUX ~= nil then
|
||||
vim.keymap.set('n', '<f5>', function()
|
||||
vim.cmd.write()
|
||||
local file = vim.api.nvim_buf_get_name(0)
|
||||
local command = vim.g.vimux_command or 'make'
|
||||
vim.fn.VimuxRunCommand(command:format(file))
|
||||
end)
|
||||
vim.keymap.set('n', '<f6>', vim.fn.VimuxCloseRunner, { silent = true })
|
||||
end
|
||||
Reference in New Issue
Block a user