summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/setup/lspconfig.lua
blob: f025d4af5881a647b8ed7af5f7914f73275f024e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require("nvim-lsp-installer").setup {}
local lspconfig = require("lspconfig")

local function on_attach()
    vim.cmd('doautocmd User lspAttached')
    vim.cmd('augroup Format')
    vim.cmd('autocmd! * <buffer>')
    vim.cmd('autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()')
    vim.cmd('augroup END')
end

lspconfig.sumneko_lua.setup {
    on_attach = on_attach,
    settings = {
        Lua = {
            diagnostics = {
                globals = { 'vim' }
            }
        }
    }
}

lspconfig.rust_analyzer.setup {
    on_attach = on_attach,
}

-- local pid = vim.fn.getpid()
-- local omnisharp_bin = "mono /home/adam/.local/share/nvim/lsp_servers/omnisharp/omnisharp-mono/OmniSharp.exe"
lspconfig.omnisharp.setup {
    use_mono = true,
    on_attach = on_attach,
    -- cmd = { omnisharp_bin, "--languageserver", "--hostPID", tostring(pid) },
}

-- vim.cmd("let g:tex_flavor = 'tex'")
-- lspconfig.texlab.setup {
--     on_attach = on_attach,
-- }

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