From 12178dd96cc3ff549c50933b807fb8f7430d9165 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Mon, 11 Mar 2024 17:20:26 +0530 Subject: [PATCH] NVIM - VIM options updated for: autowrite, formatoptions, conceallevel, sidescrolloff, updatetime, wildmode - LSP_config: options to display diagnostic icons, inlay hints - Lint: codespell on "*" removed it wasn't working - Formatting: ignore errors - LuaSnip: Tab fix reversed, interfered with regular operations - NVIM: Options for splitkeep & markdown_recommended_style --- common/.config/nvim/lua/config/options.lua | 3 +++ .../nvim/lua/plugins/code-completion.lua | 19 +++++++------- .../nvim/lua/plugins/code-formatting.lua | 4 ++- common/.config/nvim/lua/plugins/code-lint.lua | 1 - common/.config/nvim/lua/plugins/code-lsp.lua | 26 +++++++++++++++---- common/.vim/configs.vim | 8 ++++-- 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/common/.config/nvim/lua/config/options.lua b/common/.config/nvim/lua/config/options.lua index 0f39e60..86a283f 100644 --- a/common/.config/nvim/lua/config/options.lua +++ b/common/.config/nvim/lua/config/options.lua @@ -14,3 +14,6 @@ vim.opt.backupdir = vim.fn.stdpath("config") .. "/backup/" vim.opt.wrap = true vim.opt.cursorline = true vim.opt.inccommand = "split" -- With :%s command, show the preview in a split instead of inline +vim.opt.splitkeep = "screen" +-- Fix markdown indentation settings +vim.g.markdown_recommended_style = 0 diff --git a/common/.config/nvim/lua/plugins/code-completion.lua b/common/.config/nvim/lua/plugins/code-completion.lua index d6598c5..097f464 100644 --- a/common/.config/nvim/lua/plugins/code-completion.lua +++ b/common/.config/nvim/lua/plugins/code-completion.lua @@ -74,16 +74,15 @@ return { { "L3MON4D3/LuaSnip", keys = { - -- TODO: Verify if this fixed the tab-going-crazy-sometimes issue - -- { - -- "", - -- function() - -- return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" - -- end, - -- expr = true, - -- silent = true, - -- mode = "i", - -- }, + { + "", + function() + return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + end, + expr = true, + silent = true, + mode = "i", + }, { "", function() diff --git a/common/.config/nvim/lua/plugins/code-formatting.lua b/common/.config/nvim/lua/plugins/code-formatting.lua index 0a76f51..b2e6c95 100644 --- a/common/.config/nvim/lua/plugins/code-formatting.lua +++ b/common/.config/nvim/lua/plugins/code-formatting.lua @@ -29,9 +29,11 @@ return { format_on_save = { lsp_fallback = true, async = false, - timeout_ms = 1000, + timeout_ms = 3000, + quiet = false, }, formatters = { + injected = { options = { ignore_errors = true } }, shfmt = { prepend_args = { "-i", "4" }, }, diff --git a/common/.config/nvim/lua/plugins/code-lint.lua b/common/.config/nvim/lua/plugins/code-lint.lua index 677581b..8faeba0 100644 --- a/common/.config/nvim/lua/plugins/code-lint.lua +++ b/common/.config/nvim/lua/plugins/code-lint.lua @@ -20,7 +20,6 @@ return { typescriptreact = { "codespell" }, javascriptreact = { "codespell" }, html = { "codespell" }, - ["*"] = { "codespell" }, } local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) diff --git a/common/.config/nvim/lua/plugins/code-lsp.lua b/common/.config/nvim/lua/plugins/code-lsp.lua index 35143a6..d50b9a7 100644 --- a/common/.config/nvim/lua/plugins/code-lsp.lua +++ b/common/.config/nvim/lua/plugins/code-lsp.lua @@ -36,14 +36,11 @@ return { -- Automatically install LSPs to stdpath for neovim { "williamboman/mason.nvim", config = true }, { "williamboman/mason-lspconfig.nvim" }, + { "folke/neodev.nvim" }, -- Useful status updates for LSP { "j-hui/fidget.nvim", opts = {} }, - - { "folke/neodev.nvim" }, }, - -- WARN: DO NOT do `config` here it would override `config` from coding-formatting.lua - -- That's why we do the LSP config inside mason-lspconfig }, { @@ -68,7 +65,7 @@ return { Lua = { workspace = { checkThirdParty = false }, telemetry = { enable = false }, - -- hint = { enable = true }, + completion = { callSnippet = "Replace" }, -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- diagnostics = { disable = { 'missing-fields' } }, }, @@ -127,10 +124,29 @@ return { mason_lspconfig.setup_handlers({ function(server_name) require("lspconfig")[server_name].setup({ + inlay_hints = { enabled = true }, capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], filetypes = (servers[server_name] or {}).filetypes, + diagnostics = { + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + }, + severity_sort = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = require("config.util").icons.diagnostics.Error, + [vim.diagnostic.severity.WARN] = require("config.util").icons.diagnostics.Warn, + [vim.diagnostic.severity.HINT] = require("config.util").icons.diagnostics.Hint, + [vim.diagnostic.severity.INFO] = require("config.util").icons.diagnostics.Info, + }, + }, + }, }) end, }) diff --git a/common/.vim/configs.vim b/common/.vim/configs.vim index e3a3414..b6393dd 100644 --- a/common/.vim/configs.vim +++ b/common/.vim/configs.vim @@ -13,10 +13,12 @@ set shortmess+=I " Disable the default Vim startup message. set shortmess+=s " Less verbose search messages set mouse+=a " Enable mouse support set encoding=utf-8 " Encoding +set autowrite " Enable auto write set autoread " Auto reload file if externally changed set nrformats-=octal " Do not let Ctrl-a + Ctrl-x work on octal format numbers -set formatoptions+=j " When joining lines with J, delete comment characters +set formatoptions=jcroqlnt " When joining lines with J, delete comment characters set display+=truncate " @@@ is displayed in the 1st column of the last screen line +set conceallevel=2 " Hide * markup for bold and italic, but not markers with substitutions set tabpagemax=50 " Max number of tabs set viminfo^=! set viewoptions-=options @@ -24,7 +26,8 @@ set nolangremap " Do not use non-English keyboards to define keymaps set list " Show tabs as >, trailing spaces as -, non-breakable space as + set signcolumn=yes " Always show the signs column (before line number column) set scrolloff=10 " Cursor always at middle of the screen -set updatetime=249 " No typing for this millisec -> write to swap file +set sidescrolloff=10 +set updatetime=200 " No typing for this millisec -> write to swap file set timeoutlen=500 " Multiple keys in keymaps must be pressed in these millisecs set noswapfile " Turn off swapfiles set history=10000 " Number of : commands to save @@ -56,6 +59,7 @@ set complete-=i set completeopt="menuone,noselect" " Better completion experience set wildmenu " List and cycle through autocomplete on set wildignorecase " Case insensitive path completion +set wildmode="longest:full,full" " Command-line completion mode " Remove trailing blank spaces on save autocmd BufWritePre * %s/\s\+$//e