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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
local lspconf = require("lspconfig")
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
lspconf.pylsp.setup{
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = {'W391'},
maxLineLength = 100
}
}
}
}
}
lspconf.phpactor.setup {
capabilities = capabilities,
on_attach = function() end,
}
lspconf.html.setup {
capabilities = capabilities,
}
lspconf.cssls.setup({
capabilities = capabilities,
})
lspconf.emmet_ls.setup({
capabilities = capabilities,
filetypes = { "html", "php" },
})
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 = {
focusable = false,
source = 'always',
header = '',
prefix = '',
},
})
vim.diagnostic.open_float = (function(orig)
return function(bufnr, opts)
local lnum = vim.api.nvim_win_get_cursor(0)[1] - 1
local opts = opts or {}
-- A more robust solution would check the "scope" value in `opts` to
-- determine where to get diagnostics from, but if you're only using
-- this for your own purposes you can make it as simple as you like
local diagnostics = vim.diagnostic.get(opts.bufnr or 0, {lnum = lnum})
local max_severity = vim.diagnostic.severity.HINT
for _, d in ipairs(diagnostics) do
-- Equality is "less than" based on how the severities are encoded
if d.severity < max_severity then
max_severity = d.severity
end
end
local border_color = ({
[vim.diagnostic.severity.HINT] = "DiagnosticHint",
[vim.diagnostic.severity.INFO] = "DiagnosticInfo",
[vim.diagnostic.severity.WARN] = "DiagnosticWarn",
[vim.diagnostic.severity.ERROR] = "DiagnosticError",
})[max_severity]
opts.border = {
{"╭", border_color},
{"─", border_color},
{"╮", border_color},
{"│", border_color},
{"╯", border_color},
{"─", border_color},
{"╰", border_color},
{"│", border_color},
}
orig(bufnr, opts)
end
end)(vim.diagnostic.open_float)
-- Show line diagnostics in floating popup on hover, except insert mode (CursorHoldI)
vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float()]]
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>")
map("n", "<leader>pp", "<cmd>lua vim.lsp.buf.format()<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>')
]]
|