aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/plugins/lsp.lua
blob: 703fa7cdfb98ee0029f4038946061764d0dbb8c7 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
local lspconf = require("lspconfig")

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true

lspconf.html.setup {
  capabilities = capabilities,
}

lspconf.cssls.setup({
  capabilities = capabilities,
})

lspconf.emmet_ls.setup({})
lspconf.tsserver.setup({
  capabilities = capabilities,
  on_attach = function() end,
})

lspconf.eslint.setup({
  capabilities = capabilities,
  on_attach = function() end,
})

local sign = function(opts)
  vim.fn.sign_define(opts.name, {
    texthl = opts.name,
    text = opts.text,
    numhl = ''
  })
end

sign({name = 'DiagnosticSignError', text = ''})
sign({name = 'DiagnosticSignWarn', text = ''})
sign({name = 'DiagnosticSignInfo', text = ''})
sign({name = 'DiagnosticSignHint', text = ''})

vim.diagnostic.config({
  signs = true,
  virtual_text = false,
  update_in_insert = true,
  underline = false,
  severity_sort = true,
  float = {
    source = 'always',
    header = '',
    prefix = '',
  },
})

require("keybinds")

map("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>")
map("n", "<C-h>", "<cmd>lua vim.diagnostic.open_float()<cr>")

map("n", "<leader>dn", "<cmd>lua vim.diagnostic.goto_next()<cr>")
map("n", "<leader>dp", "<cmd>lua vim.diagnostic.goto_prev()<cr>")

--[[
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K     <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gD    <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> 1gD   <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> gr    <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0    <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> gW    <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
nnoremap <silent> gd    <cmd>lua vim.lsp.buf.definition()<CR> 

-- Jump to the definition
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')

-- Jump to declaration
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')

-- Lists all the implementations for the symbol under the cursor
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')

-- Jumps to the definition of the type symbol
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')

-- Lists all the references 
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')

-- Displays a function's signature information
bufmap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>')

-- Renames all references to the symbol under the cursor
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')

-- Selects a code action available at the current cursor position
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
bufmap('x', '<F4>', '<cmd>lua vim.lsp.buf.range_code_action()<cr>')

-- Show diagnostics in a floating window
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
]]