all repos

init.lua @ 6a7a03f

my nvim config

init.lua/lua/fk/lsp/init.lua(view raw)

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
local diagnostic = require "fk.lsp.diagnostic"
local on_attach = require "fk.lsp.attach"
local M = {}

function M.setup()
  vim.diagnostic.config(diagnostic)
  for _, sign in ipairs(diagnostic.signs.active) do
    vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
  end

  require "fk.lsp.null"
  require("nvim-lsp-installer").on_server_ready(function(server)
    local opts = {
      on_attach = on_attach,
      capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()),
      flags = { debounce_text_changes = 150 },
    }

    local ok, server_opts = pcall(require, "fk.lsp.providers." .. server.name)
    if ok then
      opts = vim.tbl_deep_extend("force", opts, server_opts or {})
    end

    if server.name == "rust_analyzer" then
      opts = vim.tbl_deep_extend("force", server:get_default_options(), opts)
      require "fk.plugin.rust-tools"(opts)
      server:attach_buffers()
      return
    end

    if server.name == "sumneko_lua" then
      opts = vim.tbl_extend("force", opts or {}, require("lua-dev").setup { lspconfig = server:get_default_options() })
    end

    server:setup(opts)
    vim.cmd [[ do User LspAttachBuffers ]]
  end)
end

return M