modify lua init

This commit is contained in:
2023-05-16 15:31:46 -04:00
parent 6d7a383491
commit d77d0f2e35
11 changed files with 411 additions and 183 deletions

View File

View File

@@ -0,0 +1,29 @@
local map = vim.api.nvim_set_keymap
local harp = require('harpoon.ui')
local harpmap = function(cmd, cb)
map('n', cmd, '', {
noremap = true,
silent = true,
callback = cb,
})
end
local nav_file = function(n)
return function()
harp.nav_file(n)
end
end
harpmap('<Leader>ee', require('harpoon.mark').add_file)
harpmap('<Leader>fh', harp.toggle_quick_menu)
harpmap('<Leader>1', nav_file(1))
harpmap('<Leader>2', nav_file(2))
harpmap('<Leader>3', nav_file(3))
harpmap('<Leader>4', nav_file(4))
harpmap('<Leader>5', nav_file(5))
harpmap('<Leader>6', nav_file(6))
harpmap('<Leader>7', nav_file(7))
harpmap('<Leader>8', nav_file(8))
harpmap('<Leader>9', nav_file(9))

View File

@@ -58,4 +58,8 @@ Plug 'tpope/vim-dispatch'
vim.call('plug#end')
require("plugins/floaterm")
require("plugins/harpoon")
require("plugins/telescope")
require("plugins/treesitter")
require("plugins/nvim-cmp")

View File

@@ -0,0 +1,73 @@
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' },
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})

View File

@@ -0,0 +1,21 @@
local map = vim.api.nvim_set_keymap
local tele = require('telescope.builtin')
local telemap = function(cmd, cb)
map('n', cmd, '', {
noremap = true,
silent = true,
callback = cb,
})
end
telemap('<Leader>ff', function() tele.find_files({ hidden = true, file_ignore_patterns = {'^.git'} }) end)
telemap('<Leader>fg', tele.live_grep)
telemap('<Leader>fb', tele.buffers)
telemap('<Leader>ft', tele.grep_string)
telemap('<Leader>tr', tele.treesitter)