FULL LUA! plus some bugfixes

This commit is contained in:
Jacob Bohanon
2023-08-22 12:07:26 -04:00
parent a9164da3a8
commit 762faaef35
19 changed files with 70 additions and 370 deletions

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

@@ -0,0 +1,11 @@
vim.api.nvim_create_augroup('jbohanon', {clear=true})
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*',
group = 'jbohanon',
command = '%s/\\s\\+$//e',
})
vim.api.nvim_create_autocmd('FileType', {
pattern = {'yaml','cpp'},
group = 'jbohanon',
command = 'setlocal tabstop=2 softtabstop=2 sw=2 expandtab indentkeys-=0# indentkeys-=<:>',
})

View File

@@ -39,3 +39,9 @@ tnoremap('<Esc>', '<c-\\><c-n>')
vnoremap('J', ':m \'>+1<CR>gv=gv')
vnoremap('K', ':m \'<-2<CR>gv=gv')
nnoremap('<Leader>ee', ':NvimTreeFindFileToggle<cr>')
vnoremap('<Leader>/', ':Commentary<cr>')
-- golang error handling
nnoremap('<Leader>err', 'oif err != nil {<CR>return nil, err<CR>}<CR><esc>kkI<esc>')

View File

@@ -22,7 +22,7 @@ local on_attach = function(client, bufnr)
vim.keymap.set('n', 'gd', require'telescope.builtin'.lsp_definitions, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', require'telescope.builtin'.lsp_implementations, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<C-s>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)

View File

@@ -0,0 +1,2 @@
vim.g["airline#extensions#tabline#enabled"] = 1
vim.g.airline_powerline_fonts = 1

View File

@@ -0,0 +1,26 @@
local map = vim.api.nvim_set_keymap
local noremap = function(ctx, keys, cmd, opts)
opts = opts or {}
opts['noremap'] = true
opts['silent'] = true
map(ctx, keys, cmd, opts)
end
local nnoremap = function(keys, cmd)
noremap('n', keys, cmd, nil)
end
local tnoremap = function(keys, cmd)
noremap('t', keys, cmd, nil)
end
vim.g.floaterm_wintype = 'split'
vim.g.floaterm_height = 0.2
nnoremap('<F7>', ':FloatermNew<CR>')
tnoremap('<F7>', '<C-\\><C-n>:FloatermNew<CR>')
nnoremap('<F8>', ':FloatermPrev<CR>')
tnoremap('<F8>', '<C-\\><C-n>:FloatermPrev<CR>')
nnoremap('<F9>', ':FloatermNext<CR>')
tnoremap('<F9>', '<C-\\><C-n>:FloatermNext<CR>')
nnoremap('<F12>', ':FloatermToggle<CR>')
tnoremap('<F12>', '<C-\\><C-n>:FloatermToggle<CR>')

View File

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

View File

@@ -14,10 +14,8 @@ cmp.setup({
["<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()
-- elseif has_words_before() then
-- cmp.complete()
else
fallback()
end
@@ -25,8 +23,6 @@ cmp.setup({
["<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
@@ -35,7 +31,7 @@ cmp.setup({
['<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.
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },

View File

@@ -0,0 +1,8 @@
vim.g.go_highlight_fields = 1
vim.g.go_highlight_functions = 1
vim.g.go_highlight_function_calls = 1
vim.g.go_highlight_extra_types = 1
vim.g.go_highlight_operators = 1
vim.g.go_fmt_autosave = 1
vim.g.go_fmt_command = 'goimports'
vim.g.go_auto_type_info = 1

View File

@@ -25,3 +25,5 @@ vim.api.nvim_set_option('backup', false)
vim.api.nvim_set_option('undofile', true)
vim.api.nvim_set_option('undodir', vim.fn.expand('~')..'/.vim/undodir')
-- Completion config
vim.api.nvim_set_option('completeopt', 'menu,menuone,noselect,noinsert,preview')

View File

@@ -1,3 +1,5 @@
vim.api.nvim_set_option('laststatus', 2)
vim.cmd('colorscheme gruvbox')
local themegroup = vim.api.nvim_create_augroup('themegroup', { clear = true })
vim.api.nvim_create_autocmd('ColorScheme', {