added lsp-functionality with custom colors
This commit is contained in:
parent
7b8cd338db
commit
f06f28643c
4 changed files with 102 additions and 4 deletions
88
nvim/.config/nvim/after/plugin/lspconfig.lua
Normal file
88
nvim/.config/nvim/after/plugin/lspconfig.lua
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
|
vim.keymap.set('n', '<leader>K', vim.lsp.buf.hover, bufopts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
|
vim.keymap.set('n', '<leader><C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
|
vim.keymap.set('n', '<space>fm', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||||
|
end
|
||||||
|
|
||||||
|
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 })
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local border = {
|
||||||
|
{ "╭", "FloatBorder" },
|
||||||
|
{ "─", "FloatBorder" },
|
||||||
|
{ "╮", "FloatBorder" },
|
||||||
|
{ "│", "FloatBorder" },
|
||||||
|
{ "╯", "FloatBorder" },
|
||||||
|
{ "─", "FloatBorder" },
|
||||||
|
{ "╰", "FloatBorder" },
|
||||||
|
{ "│", "FloatBorder" },
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
float = { border = border },
|
||||||
|
virtual_text = {
|
||||||
|
prefix = '▎', -- Could be '●', '■', 'x'
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
-- LSP settings (for overriding per client)
|
||||||
|
local handlers = {
|
||||||
|
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
|
||||||
|
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }),
|
||||||
|
}
|
||||||
|
|
||||||
|
require("mason").setup({
|
||||||
|
ui = {
|
||||||
|
border = "rounded",
|
||||||
|
icons = {
|
||||||
|
package_installed = "✔",
|
||||||
|
package_pending = "➜",
|
||||||
|
package_uninstalled = "✘"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
require("mason-lspconfig").setup({
|
||||||
|
ensure_installed = { "sumneko_lua" }
|
||||||
|
})
|
||||||
|
|
||||||
|
require("mason-lspconfig").setup_handlers {
|
||||||
|
-- The first entry (without a key) will be the default handler
|
||||||
|
-- and will be called for each installed server that doesn't have
|
||||||
|
-- a dedicated handler.
|
||||||
|
function(server_name) -- default handler (optional)
|
||||||
|
require("lspconfig")[server_name].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
handlers = handlers,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
|
@ -125,7 +125,6 @@ cmp.setup({
|
||||||
}, {
|
}, {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
-- Set configuration for specific filetype.
|
||||||
cmp.setup.filetype('gitcommit', {
|
cmp.setup.filetype('gitcommit', {
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
-- setting colors
|
-- setting colors
|
||||||
|
|
||||||
-- everforest
|
-- everforest
|
||||||
vim.api.nvim_set_var("everforest_background", "hard")
|
vim.api.nvim_set_var("everforest_background", "hard")
|
||||||
vim.api.nvim_set_var("everforest_transparent_background", "1")
|
vim.api.nvim_set_var("everforest_transparent_background", "1")
|
||||||
|
@ -40,6 +39,15 @@ vim.api.nvim_set_hl(0, "VertSplit", {bg = "none", fg = "#1d2021"})
|
||||||
vim.api.nvim_set_hl(0, "Cursorline", {bg = "#141617"})
|
vim.api.nvim_set_hl(0, "Cursorline", {bg = "#141617"})
|
||||||
vim.api.nvim_set_hl(0, "CursorLineNr", {bold = true, bg = "#141617", fg = "#d8a657"})
|
vim.api.nvim_set_hl(0, "CursorLineNr", {bold = true, bg = "#141617", fg = "#d8a657"})
|
||||||
|
|
||||||
|
-- color of Floats and FloatBorders
|
||||||
|
vim.api.nvim_set_hl(0, "NormalFloat", {bg = none, fg = none })
|
||||||
|
vim.api.nvim_set_hl(0, "FloatBorder", {bg = none, fg = "#d4be98"})
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "DiagnosticFloatingWarn", {bg = none, fg = "#d8a657"})
|
||||||
|
vim.api.nvim_set_hl(0, "DiagnosticFloatingError", {bg = none, fg = "#ea6962"})
|
||||||
|
vim.api.nvim_set_hl(0, "DiagnosticFloatingHint", {bg = none, fg = "#a9b665"})
|
||||||
|
vim.api.nvim_set_hl(0, "DiagnosticFloatingInfo", {bg = none, fg = "#d4be98"})
|
||||||
|
|
||||||
-- transparent background in active, non active and at the end of buffer for colorschemes which does not support such options
|
-- transparent background in active, non active and at the end of buffer for colorschemes which does not support such options
|
||||||
-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||||
-- vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" })
|
-- vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" })
|
||||||
|
|
|
@ -28,9 +28,12 @@ return require('packer').startup(function(use)
|
||||||
use 'lukas-reineke/indent-blankline.nvim'
|
use 'lukas-reineke/indent-blankline.nvim'
|
||||||
|
|
||||||
-- LSP
|
-- LSP
|
||||||
|
use {
|
||||||
|
{'williamboman/mason.nvim'},
|
||||||
|
{'williamboman/mason-lspconfig.nvim'},
|
||||||
|
{'neovim/nvim-lspconfig'},
|
||||||
|
}
|
||||||
-- Autocomplete
|
-- Autocomplete
|
||||||
use 'neovim/nvim-lspconfig'
|
|
||||||
use {
|
use {
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
requires = {
|
requires = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue