mirror of
https://github.com/halfdan/dotfiles.git
synced 2025-09-10 11:46:25 +00:00
Severel changes.
This commit is contained in:
@@ -5,16 +5,12 @@ local inoremap = Remap.inoremap
|
||||
vim.fn.sign_define("DiagnosticSignError", {text = "", texthl = "DiagnosticSignError"})
|
||||
vim.fn.sign_define("DiagnosticSignWarn", {text = "", texthl = "DiagnosticSignWarn"})
|
||||
vim.fn.sign_define("DiagnosticSignInfo", {text = "", texthl = "DiagnosticSignInfo"})
|
||||
vim.fn.sign_define("DiagnosticSignHint", {text = "", texthl = "DiagnosticSignHint"})
|
||||
-- vim.fn.sign_define("DiagnosticSignHint", {text = "", texthl = "DiagnosticSignHint"})
|
||||
|
||||
-- Set Default Prefix.
|
||||
-- Note: You can set a prefix per lsp server in the lv-globals.lua file
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
-- virtual_text = {
|
||||
-- prefix = "",
|
||||
-- spacing = 1,
|
||||
-- },
|
||||
signs = true,
|
||||
underline = true,
|
||||
}
|
||||
@@ -42,6 +38,7 @@ local levels = {
|
||||
"DEBUG",
|
||||
[0] = "TRACE",
|
||||
}
|
||||
---@diagnostic disable-next-line: unused-vararg
|
||||
vim.lsp.handlers["window/showMessage"] = function(_, result, ...)
|
||||
if require("vim.lsp.log").should_log(convert_lsp_log_level_to_neovim_log_level(result.type)) then
|
||||
vim.notify(result.message, levels[result.type])
|
||||
@@ -50,63 +47,36 @@ end
|
||||
|
||||
-- symbols for autocomplete
|
||||
vim.lsp.protocol.CompletionItemKind = {
|
||||
" (Text) ",
|
||||
" (Method)",
|
||||
" (Function)",
|
||||
" (Constructor)",
|
||||
" ﴲ (Field)",
|
||||
"[] (Variable)",
|
||||
" (Class)",
|
||||
" ﰮ (Interface)",
|
||||
" (Module)",
|
||||
" 襁 (Property)",
|
||||
" (Unit)",
|
||||
" (Value)",
|
||||
" 練 (Enum)",
|
||||
" (Keyword)",
|
||||
" (Snippet)",
|
||||
" (Color)",
|
||||
" (File)",
|
||||
" (Reference)",
|
||||
" (Folder)",
|
||||
" (EnumMember)",
|
||||
" ﲀ (Constant)",
|
||||
" ﳤ (Struct)",
|
||||
" (Event)",
|
||||
" (Operator)",
|
||||
" (TypeParameter)"
|
||||
" (Text) ",
|
||||
" (Method)",
|
||||
" (Function)",
|
||||
" (Constructor)",
|
||||
" ﴲ (Field)",
|
||||
"[] (Variable)",
|
||||
" (Class)",
|
||||
" ﰮ (Interface)",
|
||||
" (Module)",
|
||||
" 襁 (Property)",
|
||||
" (Unit)",
|
||||
" (Value)",
|
||||
" 練 (Enum)",
|
||||
" (Keyword)",
|
||||
" (Snippet)",
|
||||
" (Color)",
|
||||
" (File)",
|
||||
" (Reference)",
|
||||
" (Folder)",
|
||||
" (EnumMember)",
|
||||
" ﲀ (Constant)",
|
||||
" ﳤ (Struct)",
|
||||
" (Event)",
|
||||
" (Operator)",
|
||||
" (TypeParameter)"
|
||||
}
|
||||
|
||||
local function documentHighlight(client, bufnr)
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646
|
||||
hi LspReferenceText cterm=bold ctermbg=red guibg=#464646
|
||||
hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
|
||||
augroup lsp_document_highlight
|
||||
autocmd! * <buffer>
|
||||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
augroup END
|
||||
]],
|
||||
false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
-- -- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir)
|
||||
-- vim.cmd([[
|
||||
-- au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
|
||||
-- au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir
|
||||
-- au BufRead,BufNewFile mix.lock set filetype=elixir
|
||||
-- ]])
|
||||
|
||||
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>Lspsaga show_line_diagnostics<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', { noremap = true, silent = true })
|
||||
|
||||
-- LSP settings
|
||||
@@ -116,16 +86,19 @@ lsp_status.register_progress()
|
||||
local lspconfig = require 'lspconfig'
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
nnoremap("gd", function() vim.lsp.buf.definition() end)
|
||||
nnoremap("gd", "<cmd>Lspsaga peek_definition<CR>")
|
||||
nnoremap("<leader>gd", function ()
|
||||
vim.lsp.buf.definition()
|
||||
end)
|
||||
nnoremap("gD", function() vim.lsp.buf.declaration() end)
|
||||
nnoremap("K", function() vim.lsp.buf.hover() end)
|
||||
nnoremap("K", "<cmd>Lspsaga hover_doc<CR>")
|
||||
nnoremap("gW", function() vim.lsp.buf.workspace_symbol() end)
|
||||
nnoremap("<leader>vd", function() vim.diagnostic.open_float() end)
|
||||
nnoremap("[d", function() vim.diagnostic.goto_next() end)
|
||||
nnoremap("]d", function() vim.diagnostic.goto_prev() end)
|
||||
nnoremap("<leader>ca", function() vim.lsp.buf.code_action() end)
|
||||
nnoremap("[d", "<cmd>Lspsaga diagnostic_jump_next<CR>")
|
||||
nnoremap("]d", "<cmd>Lspsaga diagnostic_jump_prev<CR>")
|
||||
nnoremap("<leader>ca", "<cmd>Lspsaga code_action<CR>")
|
||||
nnoremap("gr", function() vim.lsp.buf.references() end)
|
||||
nnoremap("<leader>rn", function() vim.lsp.buf.rename() end)
|
||||
nnoremap("<leader>rn", "<cmd>Lspsaga rename<CR>")
|
||||
nnoremap("<leader>cl", function() vim.lsp.codelens.run() end)
|
||||
nnoremap("<leader>fa", function() vim.lsp.buf.format{async = true} end)
|
||||
inoremap("<C-h>", function() vim.lsp.buf.signature_help() end)
|
||||
@@ -187,18 +160,26 @@ lspconfig.sumneko_lua.setup(config({
|
||||
}
|
||||
}))
|
||||
|
||||
-- Generic language server. Used to run credo
|
||||
lspconfig.efm.setup(config({
|
||||
on_attach = on_attach,
|
||||
filetypes = {"elixir"}
|
||||
}))
|
||||
|
||||
require('rust-tools').setup({
|
||||
tools = {
|
||||
inlay_hints = {
|
||||
parameter_hints_prefix = "← ",
|
||||
other_hints_prefix = "➜ ",
|
||||
}
|
||||
tools = {
|
||||
runnables = {
|
||||
use_telescope = true,
|
||||
},
|
||||
inlay_hints = {
|
||||
auto = true,
|
||||
parameter_hints_prefix = "",
|
||||
other_hints_prefix = "",
|
||||
}
|
||||
},
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
checkOnSave = {
|
||||
command = "clippy",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user