Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- LSP stuff
- local nvim_lsp = require('lspconfig')
- local lsp_util = require('lspconfig.util')
- local langs = {
- hls = {},
- rust_analyzer = {
- settings = {
- ["rust-analyzer"] = {
- procMacro = { enable = false }
- }
- }
- },
- clangd = {},
- texlab = {
- settings = {
- args = {"-pdf", "--shell-escape"}
- }
- },
- erlangls = {},
- eslint = {},
- pylsp = {},
- solargraph = { root_dir = lsp_util.root_pattern("Gemfile", ".git", ".svn", ".solargraph.yml") },
- -- ruby_ls = { root_dir = lsp_util.root_pattern("Gemfile", ".git", ".svn") },
- cmake = {},
- }
- local custom_attach = function(client, bufnr_)
- bufnr = 0
- local function map(mode, key, value)
- vim.keymap.set(mode,key,value,{noremap = true, silent = true, buffer = bufnr})
- end
- local function nmap(key, value) map('n', key, value) end
- local function set_option(opt, val)
- vim.api.nvim_buf_set_option(bufnr_, opt, val)
- end
- set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
- nmap('gd', vim.lsp.buf.definition)
- nmap('gd', vim.lsp.buf.definition)
- nmap('gd', vim.lsp.buf.definition)
- nmap('gd', vim.lsp.buf.definition)
- nmap('gd', vim.lsp.buf.definition)
- nmap('gd', vim.lsp.buf.definition)
- nmap('gD', vim.lsp.buf.type_definition)
- nmap('gr', vim.lsp.buf.references)
- nmap('gR', vim.lsp.buf.rename)
- map('v', 'K', vim.lsp.buf.hover)
- nmap('K', vim.lsp.buf.hover)
- nmap('ga', vim.lsp.buf.code_action)
- nmap('=f', vim.lsp.buf.format)
- nmap('].', vim.diagnostic.goto_next)
- nmap('[.', vim.diagnostic.goto_prev)
- nmap('<leader>i', function () vim.diagnostic.open_float(0, { scope = "line", padding="single" }) end)
- nmap('<leader>d', vim.lsp.buf.code_action)
- nmap('<leader>q', vim.diagnostic.setqflist)
- end
- for lang,opts in pairs(langs) do
- nvim_lsp[lang].setup(opts)
- nvim_lsp[lang].setup { on_attach = custom_attach }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement