1
0

Lualine and LSP tweaks

This commit is contained in:
Patrick Auernig 2023-05-09 17:28:09 +02:00
parent 80befc33f8
commit c8ac4bf07f
3 changed files with 50 additions and 41 deletions

View File

@ -11,10 +11,10 @@ lsp.nvim_workspace()
local cmp = require("cmp")
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mapping = lsp.defaults.cmp_mappings({
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
})
lsp.setup_nvim_cmp({ mapping = cmp_mapping })
@ -23,25 +23,28 @@ vim.diagnostic.config({
virtual_text = false,
})
vim.keymap.set("n", "<Leader>ci", vim.diagnostic.open_float, { desc = "Display diagnostic Code Info" })
-- Gimme pretty icons
lsp.set_sign_icons({
error = '',
warn = '',
hint = '',
info = '»'
error = '',
warn = '',
hint = '',
info = '»'
})
lsp.on_attach(function(_, buffnr)
lsp.on_attach(function(_, buffnr)
local opts = { buffer = buffnr, remap = false }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<Leader>re", vim.lsp.buf.rename, opts)
vim.keymap.set({"n", "i"}, "<C-h>", vim.lsp.buf.signature_help, opts)
vim.keymap.set({ "n", "i" }, "<C-h>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<Leader>fmt", function()
vim.lsp.buf.format({ async = false, timeout_ms = 5000 })
vim.lsp.buf.format({ async = false, timeout_ms = 5000 })
end)
end)
@ -49,12 +52,10 @@ end)
-- NOTE: Format on save does not support async formatting
lsp.format_on_save({
servers = {
["rust_analyzer"] = {"rust"}
["rust_analyzer"] = { "rust" }
}
})
require("lsp-inlayhints").setup()
lsp.setup()
require("lsp-inlayhints").setup()

31
after/plugin/lualine.lua Normal file
View File

@ -0,0 +1,31 @@
local overseer = require("overseer")
local task_status = {
"overseer",
colored = true,
symbols = {
[overseer.STATUS.FAILURE] = "",
[overseer.STATUS.CANCELED] = "o ",
[overseer.STATUS.SUCCESS] = "",
[overseer.STATUS.RUNNING] = "",
},
}
require("lualine").setup({
sections = {
lualine_b = {
"branch",
"diff",
{
"diagnostics",
symbols = { error = "E:", warn = "W:", info = "I:", hint = "H:" }
},
},
lualine_x = {
task_status,
"encoding",
{ "fileformat", icons_enabled = false },
"filetype"
}
},
})

View File

@ -102,32 +102,9 @@ local function spec(use)
use {
"nvim-lualine/lualine.nvim",
requires = {
{ "nvim-tree/nvim-web-devicons" }
},
config = function()
local overseer = require("overseer")
local task_status = {
"overseer",
colored = true,
symbols = {
[overseer.STATUS.FAILURE] = "",
[overseer.STATUS.CANCELED] = "o",
[overseer.STATUS.SUCCESS] = "",
[overseer.STATUS.RUNNING] = "",
},
}
require("lualine").setup({
sections = {
lualine_x = {
task_status,
"encoding",
{ "fileformat", icons_enabled = false },
"filetype"
}
},
})
end
{ "nvim-tree/nvim-web-devicons" },
{ "stevearc/overseer.nvim" },
}
}
use {