From 822b092d1533065a0f347f2bb7cc685f605a2f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Wed, 14 Aug 2024 18:35:58 +0200 Subject: [PATCH] Try to override statusline modules --- lua/core/default_config.lua | 12 ---------- lua/core/init.lua | 2 +- lua/core/mappings.lua | 25 ++++++++++++-------- lua/core/utils.lua | 3 +++ lua/custom/chadrc.lua | 38 ++++++++++++++++++++++++++++++- lua/plugins/configs/lspconfig.lua | 9 ++++++++ lua/plugins/init.lua | 8 ++++++- 7 files changed, 73 insertions(+), 24 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index b95075c..2a5a901 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -35,18 +35,6 @@ M.ui = { -- default/round/block/arrow separators work only for default statusline theme -- round and block will work for minimal theme only separator_style = "default", - overriden_modules = function(modules) - modules[1] = (function() - local noice = require("noice") - if noice.api.statusline.mode.has() then - return "%#St_CommandMode#" .. noice.api.statusline.mode.get() .. modules[1] - end - return modules[1] - end)() - end, - fileInfo = function() - return require("nvchad_ui.statusline.default.fileInfo").run() - end, }, -- lazyload it when there are 1+ buffers diff --git a/lua/core/init.lua b/lua/core/init.lua index e02514d..dc38c9a 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -61,7 +61,7 @@ for _, provider in ipairs { "node", "perl", "python3", "ruby" } do end -- add binaries installed by mason.nvim to path -local is_windows = vim.fn.has("win32") ~= 0 +local is_windows = vim.fn.has "win32" ~= 0 vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH -------------------------------------- autocmds ------------------------------------------ diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 473a4af..1f19222 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -59,6 +59,14 @@ M.general = { -- ["y"] = {" :w! /tmp/vimtmp", "Save into a global tmp file"}, -- ["p"] = {" :r! cat /tmp/vimtmp", "Restore from the global tmp file"}, + -- (Double) Trouble + ["tx"] = { ":Trouble diagnostics toggle", "[T]rouble diagnostics" }, + ["tX"] = { ":Trouble diagnostics toggle filter.buf=0", "[T]rouble buffer diagnostics" }, + ["ts"] = { ":Trouble symbols toggle focus=false", "[T]rouble [S]ymbols" }, + ["tl"] = { ":Trouble lsp toggle focus=false win.position=right", "[T]rouble [L]sp def / ref / ..." }, + ["tL"] = { ":Trouble loclist toggle", "[T]rouble [L]oclist" }, + ["tQ"] = { ":Trouble qflist toggle", "[T]rouble [Q]uickfix" }, + ["dgg"] = { ":lua require('dap').continue() ", "Continue debu[g]ging" }, ["dg"] = { ":lua require('dapui').toggle() ", "Toggle DAP ui" }, ["dgw"] = { ":lua require('dapui').eval() ", "Open floating windows about current [w]ord" }, @@ -227,12 +235,12 @@ M.tabufline = { }, -- close buffer + hide terminal buffer - ["x"] = { - function() - require("nvchad.tabufline").close_buffer() - end, - "Close buffer", - }, + -- ["x"] = { + -- function() + -- require("nvchad.tabufline").close_buffer() + -- end, + -- "Close buffer", + -- }, }, } @@ -523,8 +531,7 @@ M.telescope = { ["pt"] = { " Telescope terms ", "Pick hidden term" }, -- theme switcher - ["th"] = { " Telescope themes ", "Nvchad themes" }, - + -- ["th"] = { " Telescope themes ", "Nvchad themes" }, ["ma"] = { " Telescope marks ", "telescope bookmarks" }, -- History @@ -709,7 +716,7 @@ M.gitsigns = { "Blame line", }, - ["td"] = { + ["bd"] = { function() require("gitsigns").toggle_deleted() end, diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 8b2a03d..ccc5c69 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -13,6 +13,9 @@ M.load_config = function() config.mappings.disabled = nil end + -- print(vim.inspect(config)) + -- print(config) + -- print(vim.inspect(config.ui.statusline)) return config end diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 5d20eeb..cd3f6ca 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -6,10 +6,46 @@ local highlights = require "custom.highlights" M.ui = { theme = "onedark", - theme_toggle = { "onedark", "monekai" }, + theme_toggle = { "onedark", "onedark" }, hl_override = highlights.override, hl_add = highlights.add, + + statusline = { + order = { + "macro", + "mode", + "relativepath", + "file", + "git", + "%=", + "lsp_msg", + "%=", + "diagnostics", + "lsp", + "cwd", + "cursor", + }, + modules = { + macro = function() + local noice = require "noice" + if noice.api.statusline.mode.has() then + return "%#St_CommandMode#" .. noice.api.statusline.mode.get() + end + return "" + end, + relativepath = function() + local stbufnr = vim.api.nvim_win_get_buf(vim.g.statusline_winid or 0) + local path = vim.api.nvim_buf_get_name(stbufnr) + + if path == "" then + return "" + end + + return "%#St_relativepath# " .. vim.fn.expand "%:.:h" .. " /" + end, + }, + }, } M.plugins = "custom.plugins" diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 6684c8b..da3a3fe 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -42,10 +42,17 @@ M.capabilities.textDocument.completion.completionItem = { M.capabilities.textDocument.publishDiagnostics.tagSupport.valueSet = { 2 } +-- LSP settings (for overriding per client) +M.handlers = { + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }), +} + require("lspconfig").lua_ls.setup { on_init = M.on_init, on_attach = M.on_attach, capabilities = M.capabilities, + handlers = M.handlers, settings = { Lua = { @@ -73,6 +80,7 @@ require("lspconfig").pyright.setup { on_init = M.on_init, on_attach = M.on_attach, capabilities = M.capabilities, + handlers = M.handlers, settings = { pyright = { @@ -86,6 +94,7 @@ require("lspconfig").pyright.setup { -- typeCheckingMode = "off", -- Using mypy diagnosticSeverityOverrides = { reportMissingImports = false, + reportAttributeAccessIssue = false, }, }, }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 7036687..2dbea51 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -136,7 +136,7 @@ local default_plugins = { }, }, format_on_save = { - timeout_ms = 500, + timeout_ms = 1000, lsp_format = "fallback", }, } @@ -591,6 +591,12 @@ local default_plugins = { -- refer to the configuration section below }, }, + { + "folke/trouble.nvim", + lazy = false, + cmd = "Trouble", + opts = {}, + }, } local config = require("core.utils").load_config()