call plug#begin(stdpath('data') . '/plugged') Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-vsnip' Plug 'hrsh7th/vim-vsnip' Plug 'nvim-lua/completion-nvim' Plug 'nvim-lua/diagnostic-nvim' Plug 'nvim-lua/plenary.nvim' " Dependecy for telescope Plug 'nvim-lua/telescope.nvim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Dependecy for telescope Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'rodjek/vim-puppet' Plug 'mrk21/yaml-vim' " For hieradata Plug 'vim-ruby/vim-ruby' " For Facts, Ruby functions, and custom providers Plug 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim' call plug#end() " set leaderkey let mapleader = '\' " set complete opts set completeopt=menu,menuone,noselect " Go to last edited line if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif " Telescope settings nnoremap ff Telescope find_files nnoremap fg Telescope live_grep nnoremap fb Telescope buffers nnoremap fh Telescope help_tags "" NERDTree settings "" Start NERDTree and put the cursor back in the other window. "autocmd VimEnter * NERDTree | wincmd p "" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. "autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | " \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif "" Exit Vim if NERDTree is the only window remaining in the only tab. "autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif " " lsp diagnostics lua <td (toggle-lsp-diag) " Lua config for treesitter lua < buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } -- See `:help vim.lsp.*` for documentation on any of the below functions buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'h', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'i', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) buf_set_keymap('n', 'r', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'a', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) vim.diagnostic.config({ virtual_text = true, signs = true, underline = true, update_in_insert = true, severity_sort = false, }) local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end end -- set up completion local cmp = require'cmp' cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. -- require('snippy').expand_snippet(args.body) -- For `snippy` users. -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. end, }, mapping = { [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. [''] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }), [''] = 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' }, -- For vsnip users. -- { name = 'luasnip' }, -- For luasnip users. -- { name = 'ultisnips' }, -- For ultisnips users. -- { name = 'snippy' }, -- For snippy users. }, { { name = 'buffer' }, }) }) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline('/', { sources = { { name = 'buffer' } } }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(':', { sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) -- Setup lspconfig. local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { 'pylsp', 'clangd', 'puppet', 'bashls'} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { capabilities = capabilities, on_attach = on_attach, flags = { debounce_text_changes = 150, } } end nvim_lsp["efm"].setup { capabilities = capabilities, on_attach = on_attach, flags = { debounce_text_changes = 150, }, init_options = {documentFormatting = true}, filetypes = { 'sh', 'puppet'}, settings = { rootMarkers = {".git/"}, languages = { puppet = { { formatCommand = 'puppet-fix', formatStdin = true, lintCommand = 'puppet-lint --log-format "%{filename}:%{line}:%{column}: %{kind}: %{message}. [%{check}]"', lintSource = 'puppet-lint', lintFormats= {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} } }, sh = { { formatCommand = "shfmt -i 2", formatStdin = true, lintCommand = 'shellcheck -f gcc -x', lintSource = 'shellcheck', lintFormats= {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} } } } } } EOF