Added completion and some key mappings

This commit is contained in:
2021-09-09 00:13:06 +02:00
parent f4fe34a7aa
commit 1d0a458c8f
4 changed files with 222 additions and 10 deletions

106
init.lua
View File

@ -13,8 +13,12 @@ if fn.empty(fn.glob(install_path)) > 0 then
vim.cmd 'packadd packer.nvim'
end
vim.cmd [[packadd packer.nvim]]
vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
local utils = require('utils')
-- Install plugins
require('plugins')
@ -23,10 +27,10 @@ require('keymappings')
cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here
cmd 'syntax enable'
cmd 'filetype plugin indent on'
--opt.noswapfile = true
-- opt.nobackup = true
opt.spelllang = 'en,de'
local indent = 4
utils.opt('o', 'swapfile', false)
utils.opt('o', 'backup', false)
utils.opt('o', 'spelllang', 'en,de')
local indent = 2
utils.opt('b', 'expandtab', true)
utils.opt('b', 'shiftwidth', indent)
utils.opt('b', 'smartindent', true)
@ -62,7 +66,15 @@ local ts = require 'nvim-treesitter.configs'
ts.setup {ensure_installed = 'maintained', highlight = {enable = true}}
-------------------- FZF -----------------------------------
utils.map('n', '<C-P>', ':FZF<CR>')
--utils.map('n', '<C-P>', ':FZF<CR>')
-------------------- TELESCOPE -----------------------------
utils.map('n', '<leader>f', '<cmd>Telescope find_files<cr>')
utils.map('n', '<C-p>', '<cmd>Telescope find_files<cr>')
utils.map('n', '<leader>g', '<cmd>Telescope git_files<cr>')
utils.map('n', '<leader>o', '<cmd>Telescope oldfiles<cr>')
utils.map('n', '<leader>h', '<cmd>Telescope command_history<cr>')
utils.map('n', '<C-S-p>', '<cmd>Telescope commands<cr>')
utils.map('n', '<leader>fb', '<cmd>Telescope buffers<cr>')
-------------------- LSP -----------------------------------
local lsp = require 'lspconfig'
@ -82,6 +94,84 @@ utils.map('n', '<space>r', '<cmd>lua vim.lsp.buf.references()<CR>')
utils.map('n', '<space>s', '<cmd>lua vim.lsp.buf.document_symbol()<CR>')
-------------------- GITSIGNS ------------------------------
require('gitsigns').setup()
-- require('gitsigns').setup()
-------------------- LIGHTBULB -----------------------------
require('nvim-lightbulb').update_lightbulb()
-------------------- CMP -----------------------------------
require('cmp_plug')
-- local cmp = require'cmp'
-- cmp.setup({
-- snippet = {
-- expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body)
-- end,
-- },
-- mapping = {
-- ['<C-y>'] = cmp.mapping.confirm({ select = true }),
-- },
-- sources = {
-- { name = '...' },
-- ...
-- }
-- })
-- local cmp = require 'cmp'
-- local types = require('cmp.types')
-- cmp.setup {
-- completion = {
-- autocomplete = {
-- types.cmp.TriggerEvent.TextChanged,
-- },
-- completeopt = 'menu,menuone,noselect',
-- keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]],
-- keyword_length = 1,
-- get_trigger_characters = function(trigger_characters)
-- return trigger_characters
-- end
-- },
-- snippet = {
-- expand = function(args)
-- require('luasnip').lsp_expand(args.body)
-- end,
-- },
-- mapping = {
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
-- ['<C-n>'] = cmp.mapping.select_next_item(),
-- ['<C-d>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- ['<C-Space>'] = cmp.mapping.complete(),
-- ['<C-e>'] = cmp.mapping.close(),
-- ['<CR>'] = cmp.mapping.confirm {
-- behavior = cmp.ConfirmBehavior.Replace,
-- select = true,
-- },
-- ['<Tab>'] = function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
-- elseif luasnip.expand_or_jumpable() then
-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
-- else
-- fallback()
-- end
-- end,
-- ['<S-Tab>'] = function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
-- elseif luasnip.jumpable(-1) then
-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
-- else
-- fallback()
-- end
-- end,
-- },
-- sources = {
-- { name = 'nvim_lsp' },
-- { name = 'luasnip' },
-- },
-- }
-------------------- NVIM-TREE -----------------------------
g.nvim_tree_auto_open = 1
-------------------- NVIM-COMMENT --------------------------
require('nvim_comment').setup()
require('nvim_comment').setup({line_mapping = '<C-#>', operator_mapping = '<C-#>'})
utils.map('n', '<A-#>', 'gcc')
utils.map('v', '<A-#>', 'gc')