This commit is contained in:
2023-07-31 17:35:26 +02:00
commit c285dd40be
9 changed files with 839 additions and 0 deletions

94
lua/code-completion.lua Normal file
View File

@@ -0,0 +1,94 @@
-- menuone: show also for just one code suggestion
-- noinsert: only insert text when selection confirmed
-- noselect: force to select from suggestion
-- preview: show more details
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert', 'preview'}
-- shortmess is used to reduce verbocity
-- vim.opt.shortmess = vim.opt.shortmess + { c = true }
local cmp = require'cmp'
cmp.setup( {
-- configuration
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
-- mapping
mapping = {
-- Shift+TAB to go to the Previous Suggested item
['<C-s-k>'] = cmp.mapping.select_prev_item(),
-- Tab to go to the next suggestion
['<C-k>'] = cmp.mapping.select_next_item(),
-- CTRL+SHIFT+f to scroll backwards in description
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
-- CTRL+F to scroll forwards in the description
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- CTRL+SPACE to bring up completion at current Cursor location
['<C-Space>'] = cmp.mapping.complete(),
-- CTRL+e to exit suggestion and close it
['<C-e>'] = cmp.mapping.close(),
-- CR (enter or return) to CONFIRM the currently selection suggestion
-- We set the ConfirmBehavior to insert the Selected suggestion
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
},
-- installed sources for code suggestion
sources = {
{ name = 'path' },
{ name = 'nvim_lsp', keyword_length = 3 },
{ name = 'nvim_lsp_signature_help'},
{ name = 'nvim_lua', keyword_length = 2},
{ name = 'buffer', keyword_length = 2 },
{ name = 'ultisnips', keyword_length = 2 },
{ name = 'calc' },
{ name = "lua-latex-symbols", option = { cache = true } }
},
-- Add borders to the windows
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
-- add formating of the different sources
formatting = {
fields = {'menu', 'abbr', 'kind'},
format = function(entry, item)
local menu_icon ={
nvim_lsp = 'λ',
ultisnips = '',
buffer = 'b',
path = 'p',
calc = 'Σ',
lualatexsymbols = 'L'
}
item.menu = menu_icon[entry.source.name]
return item
end,
}
} )
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ 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' }
})
})

44
lua/plugins.lua Normal file
View File

@@ -0,0 +1,44 @@
return require('packer').startup(function(use)
-- Configurations will go here soon
use 'wbthomason/packer.nvim'
use 'dense-analysis/ale'
use 'preservim/nerdtree'
use 'Xuyuanp/nerdtree-git-plugin'
use 'tpope/vim-surround'
use 'SirVer/ultisnips'
use 'vim-airline/vim-airline'
use {
'nvim-treesitter/nvim-treesitter',
run = function()
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
ts_update()
end,
}
use { 'junegunn/fzf', run = ":call fzf#install()" }
use 'junegunn/fzf.vim'
-- use 'Valloric/YouCompleteMe'
use 'williamboman/mason.nvim'
use 'williamboman/mason-lspconfig.nvim'
use 'neovim/nvim-lspconfig'
use 'mfussenegger/nvim-dap'
use 'f-person/git-blame.nvim'
use 'mfussenegger/nvim-lint'
use 'lewis6991/gitsigns.nvim'
use 'p00f/nvim-ts-rainbow'
use 'cohama/lexima.vim'
use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-nvim-lua'
use 'hrsh7th/cmp-nvim-lsp-signature-help'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-calc'
use 'amarakon/nvim-cmp-lua-latex-symbols'
use 'prabirshrestha/async.vim'
use 'prabirshrestha/vim-lsp'
use 'nvim-tree/nvim-web-devicons'
use {'romgrk/barbar.nvim', wants = 'nvim-web-devicons'}
use({"petertriho/cmp-git", requires = "nvim-lua/plenary.nvim"})
use 'quangnguyen30192/cmp-nvim-ultisnips'
use 'ryanoasis/vim-devicons'
end)

14
lua/tools.lua Normal file
View File

@@ -0,0 +1,14 @@
-- in tools.lua
local api = vim.api
local M = {};
function M.makeScratch()
vim.bo[0].buftype=nofile -- set the current buffer's (buffer 0) buftype to nofile
vim.bo[0].bufhidden=hide
vim.bo[0].swapfile=false
end;
return M;