Guest User

Untitled

a guest
Dec 18th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. local lsp = require('lspconfig')
  2. local completion = require('completion')
  3. local api = vim.api
  4. local configs = require('lspconfig/configs')
  5.  
  6. --local functi
  7. --" Set completeopt to have a better completion experience
  8. api.nvim_command('set completeopt=longest,menuone,noinsert,noselect')
  9. --" Use <Tab> and <S-Tab> to navigate through popup menu
  10. api.nvim_command('inoremap <expr> <Tab>   pumvisible() ? "<C-n>" : "<Tab>"')
  11. api.nvim_command('inoremap <expr> <S-Tab> pumvisible() ? "<C-p>" : "<S-Tab>"')
  12. --" Avoid showing message extra message when using completion
  13. api.nvim_command('set shortmess+=c')
  14. --api.nvim_command('')
  15.  
  16.  
  17. local mapper = function(mode, key, result)
  18.   vim.api.nvim_buf_set_keymap(0, mode, key, "<cmd>lua "..result.."<cr>", {noremap = true, silent = true})
  19. end
  20.  
  21.  
  22. local custom_attach = function()
  23.   completion.on_attach()
  24.   -- Move cursor to the next and previous diagnostic
  25.   mapper('n', '<leader>dn', 'vim.lsp.diagnostic.goto_next()')
  26.   mapper('n', '<leader>dp', 'vim.lsp.diagnostic.goto_prev()')
  27. end
  28.  
  29. lsp.pyls.setup{
  30.   on_attach = custom_attach
  31. }
  32. lsp.tsserver.setup {on_attach = custom_attach}
  33. lsp.jdtls.setup {on_attach = custom_attach,
  34.         root_dir = lsp.util.root_pattern('.git', 'pom.xml', 'build.xml')
  35. }
  36. lsp.sumneko_lua.setup {on_attach = custom_attach}
  37.  
  38. --another lua config that does not work either
  39. --lsp.sumneko_lua.setup{
  40.     --on_attach=custom_attach,
  41.     --settings = {
  42.         --Lua = {
  43.             --runtime = { version = "LuaJIT", path = vim.split(package.path, ';'), },
  44.             --completion = { keywordSnippet = "Enable", },
  45.             --diagnostics = { enable = true, globals = {
  46.                 --"vim", "describe", "it", "before_each", "after_each" },
  47.             --},
  48.             --workspace = {
  49.                 --library = {
  50.                     --[vim.fn.expand("$VIMRUNTIME/lua")] = true,
  51.                     --[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
  52.                 --}
  53.             --}
  54.         --}
  55.     --}
  56. --}
  57.  
Advertisement
Add Comment
Please, Sign In to add comment