diff --git a/nvim/nvim/config/nvim.ln/lua/lsp/handlers.lua b/nvim/nvim/config/nvim.ln/lua/lsp/handlers.lua index d492efa..e58fcca 100644 --- a/nvim/nvim/config/nvim.ln/lua/lsp/handlers.lua +++ b/nvim/nvim/config/nvim.ln/lua/lsp/handlers.lua @@ -5,7 +5,7 @@ M.setup = function() { name = "DiagnosticSignError", text = "" }, { name = "DiagnosticSignWarn", text = "" }, { name = "DiagnosticSignHint", text = "" }, - { name = "DiagnosticSignInfo", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, } for _, sign in ipairs(signs) do vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) @@ -25,7 +25,7 @@ M.setup = function() end local function lsp_highlight_document(client) - if client.resolved_capabilities.document_highlight then + if client.server_capabilities.documentHighlightProvider then vim.cmd [[ augroup lsp_document_highlight autocmd! * @@ -48,6 +48,15 @@ wk.register({ }, }) +function _LSP_FORMAT_FILTER(clients) + for _, v in ipairs(clients) do + if v.name == "null-ls" and v.server_capabilities.documentFormattingProvider then + return { v } + end + end + return clients +end + local lsp_keymaps = function(bufnr) wk.register({ g = { @@ -64,7 +73,7 @@ local lsp_keymaps = function(bufnr) r = { 'lua vim.lsp.buf.rename()', "Rename" }, a = { 'lua vim.lsp.buf.code_action()', "Code action" }, l = { 'lua vim.lsp.codelens.run()', "Run code lens" }, - f = { 'lua vim.lsp.buf.formatting()', "Format" }, + f = { 'lua vim.lsp.buf.format({filter=_LSP_FORMAT_FILTER})', "Format" }, g = { 'Telescope lsp_document_symbols', "Go to symbol" }, } }, { diff --git a/nvim/nvim/config/nvim.ln/lua/lsp/init.lua b/nvim/nvim/config/nvim.ln/lua/lsp/init.lua index 09d489f..89a6b86 100644 --- a/nvim/nvim/config/nvim.ln/lua/lsp/init.lua +++ b/nvim/nvim/config/nvim.ln/lua/lsp/init.lua @@ -3,4 +3,5 @@ require("lsp.handlers").setup() require "lsp.cmp" require "lsp.signature" require "lsp.metals" +require "lsp.null-ls" diff --git a/nvim/nvim/config/nvim.ln/lua/lsp/null-ls.lua b/nvim/nvim/config/nvim.ln/lua/lsp/null-ls.lua new file mode 100644 index 0000000..bab9775 --- /dev/null +++ b/nvim/nvim/config/nvim.ln/lua/lsp/null-ls.lua @@ -0,0 +1,51 @@ +local ok, nl = pcall(require, "null-ls") +if not ok then + return +end + +local sources = { + nl.builtins.code_actions.eslint, + nl.builtins.diagnostics.eslint, + nl.builtins.formatting.eslint, + nl.builtins.formatting.prettier, +} +nl.setup({ + sources = vim.tbl_map(function(source) + return source.with({ + diagnostics_postprocess = function(diagnostic) + diagnostic.severity = vim.diagnostic.severity.HINT + end, + }) + end, sources), +}) + +local function sort_ca_results(lsp_results) + local results = {} + local null_results = {} + + for client_id, result in ipairs(lsp_results) do + local client = vim.lsp.get_client_by_id(client_id) + + if client.name == "null-ls" then + table.insert(null_results, result) + else + table.insert(results, result) + end + end + + -- Sort null-ls actions to the end + return vim.list_extend(results, null_results) +end + +local buf_request_all = vim.lsp.buf_request_all +local ca +ca = function(bufnr, method, params, callback) + return buf_request_all(bufnr, method, params, function(lsp_results) + vim.lsp.buf_request_all = buf_request_all + local results = sort_ca_results(lsp_results) + local res = callback(results) + vim.lsp.buf_request_all = ca + return res + end) +end +vim.lsp.buf_request_all = ca diff --git a/nvim/nvim/config/nvim.ln/lua/plugins.lua b/nvim/nvim/config/nvim.ln/lua/plugins.lua index 5c4d322..2afc40b 100644 --- a/nvim/nvim/config/nvim.ln/lua/plugins.lua +++ b/nvim/nvim/config/nvim.ln/lua/plugins.lua @@ -52,10 +52,11 @@ return packer.startup(function(use) use { "airblade/vim-rooter", config = function() vim.g.rooter_manual_only = 1 end } use { "Pocco81/AutoSave.nvim", config = function() require "autosave".setup() end } - use { "AckslD/nvim-gfold.lua" } + use "AnonymusRaccoon/nvim-gfold.lua" + -- use { "AckslD/nvim-gfold.lua" } use { "lewis6991/spellsitter.nvim" } - use {'psliwka/vim-dirtytalk', run = ':DirtytalkUpdate'} + use { 'psliwka/vim-dirtytalk', run = ':DirtytalkUpdate' } use "ggandor/lightspeed.nvim" @@ -90,6 +91,7 @@ return packer.startup(function(use) use "Hoffs/omnisharp-extended-lsp.nvim" use({ 'scalameta/nvim-metals', requires = { "nvim-lua/plenary.nvim" } }) use "b0o/schemastore.nvim" + use "jose-elias-alvarez/null-ls.nvim" use { "hrsh7th/cmp-nvim-lsp", @@ -136,6 +138,12 @@ return packer.startup(function(use) use "tpope/vim-fugitive" use { "lewis6991/gitsigns.nvim", requires = { 'nvim-lua/plenary.nvim' } } + use({ + "iamcco/markdown-preview.nvim", + run = "cd app && npm install", + setup = function() vim.g.mkdp_filetypes = { "markdown" } end, + ft = { "markdown" }, + }) if PACKER_BOOTSTRAP then require("packer").sync() diff --git a/nvim/nvim/config/nvim.ln/lua/utils/scratchpads.lua b/nvim/nvim/config/nvim.ln/lua/utils/scratchpads.lua index 3ffad1e..867757b 100644 --- a/nvim/nvim/config/nvim.ln/lua/utils/scratchpads.lua +++ b/nvim/nvim/config/nvim.ln/lua/utils/scratchpads.lua @@ -8,7 +8,12 @@ vim.g["codi#virtual_text_pos"] = 90 local wk = require "which-key" wk.register({ - s = { "CodiSelect", "Open a Sratchpad" }, + s = { + name = "Scratchpads", + n = { "CodiSelect", "Open a Sratchpad" }, + e = { "CodiExpand", "Expand the scratchad output" }, + t = { "Codi!!", "Toggle the scratchpad output" }, + } }, { prefix = "", }) diff --git a/nvim/nvim/config/nvim.ln/lua/utils/spell.lua b/nvim/nvim/config/nvim.ln/lua/utils/spell.lua index 0b215b3..9b15017 100644 --- a/nvim/nvim/config/nvim.ln/lua/utils/spell.lua +++ b/nvim/nvim/config/nvim.ln/lua/utils/spell.lua @@ -1,7 +1,20 @@ -vim.opt.spell = true +-- vim.opt.spell = true vim.opt.spelllang = { "en", "programming" } local ok, spellsitter = pcall(require, 'spellsitter') if ok then spellsitter.setup() end + + +function MARKDOWN_PREVIEW() + local wk = require "which-key" + wk.register({ + mp = { "MarkdownPreviewToggle", "Markdown preview" }, + }, { + prefix = "", + buffer = 0, + }) +end + +vim.cmd("au FileType markdown lua MARKDOWN_PREVIEW()")