From 0bbdf294023176d7f2689fb6386e37c22eca7e43 Mon Sep 17 00:00:00 2001 From: Cryxtalix Date: Fri, 28 Feb 2025 18:01:35 +0800 Subject: Made neovim lsp warnings appear in a box rather than inline --- .bashrc | 10 +++++----- .config/nvim/init.lua | 17 +++++++++++++++++ .config/nvim/lua/plugins/lsp.lua | 35 ++++++++++++++++++++++++++++------- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/.bashrc b/.bashrc index 262a7c7..7bfa651 100644 --- a/.bashrc +++ b/.bashrc @@ -12,9 +12,9 @@ fi export PATH # Rust -if [ -d "$HOME/.cargo" ]; then - . "$HOME/.cargo/env" -fi +#if [ -d "$HOME/.cargo" ]; then +# . "$HOME/.cargo/env" +#fi # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= @@ -34,8 +34,8 @@ PS1='\[\e[1m\][ \[\e[96m\]\w \[\e[39m\]]\\$ \[\e[0m\]' HISTCONTROL=ignoredups:erasedups shopt -s histappend shopt -s checkwinsize -export HISTFILESIZE=1000 -export HISTSIZE=500 +export HISTFILESIZE=10000 +export HISTSIZE=50 export VISUAL=nvim export EDITOR="$VISUAL" alias ls="ls -F --color"; diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 112ca25..a23bed7 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -27,6 +27,23 @@ vim.api.nvim_set_keymap('v', '', '"+y', { noremap = true, silent = true }) -- end --}) +vim.diagnostic.config({ + virtual_text = false, -- Disable inline text diagnostics + signs = true, -- Keep signs in the sign column + update_in_insert = false, + underline = true, + severity_sort = true, +}) + +-- Show diagnostics on hover +vim.o.updatetime = 250 -- Faster update time for hover +vim.api.nvim_create_autocmd("CursorHold", { + pattern = "*", + callback = function() + vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" }) + end, +}) + -- Install Lazy.vim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 4e9ef07..5080622 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -12,13 +12,13 @@ return { }, { - "williamboman/mason-lspconfig.nvim", - config = function() - require("mason-lspconfig").setup { - ensure_installed = { "bashls", "lua_ls", "clangd", "marksman", "pyright", "rust_analyzer" }, - automatic_installation = true, - } - end + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup { + ensure_installed = { "bashls", "lua_ls", "clangd", "marksman", "pyright", "rust_analyzer" }, + automatic_installation = true, + } + end }, { @@ -44,6 +44,27 @@ return { }) lspconfig.rust_analyzer.setup({ capabilities = capabilities, + settings = { + ['rust-analyzer'] = { + assist = { + importEnforceGranularity = true, + importPrefix = 'crate', + }, + cargo = { + allFeatures = true, + }, + checkOnSave = { + command = 'clippy', + }, + inlayHints = { locationLinks = false }, + diagnostics = { + enable = true, + experimental = { + enable = true, + }, + }, + }, + }, }) -- Key mapping -- cgit