From 0c1681d10480364a205612825cdec486b85bb3eb Mon Sep 17 00:00:00 2001 From: blob42 Date: Sun, 6 Aug 2023 14:15:33 +0200 Subject: [PATCH 1/3] add zen mode --- lua/core/mappings.lua | 48 ++++++++++++++++++++++++++++++++++++---- lua/spike/utils/init.lua | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 3fd254d..2e1e972 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,6 +1,9 @@ -- n, v, i, t, c = mode name.s +local opt = vim.opt +local g = vim.g + local function termcodes(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end @@ -97,11 +100,37 @@ M.general = { --{{{ ["Y"] = { " %y+ ", "copy whole file" }, -- line numbers - ["n"] = { " set nu! set rnu!", "toggle line number" }, + ["N"] = { " set nu! set rnu!", "toggle line number" }, + + ["ts"] = {function() + if g.sign_column_enbaled then + opt.signcolumn="no" + g.sign_column_enbaled = false + else + opt.signcolumn="yes" + g.sign_column_enbaled = true + end + + end, "toggle sign column" }, + + ["z"] = { function() + require("spike.utils").zenmode() + end, "silent mode (no distraction)" }, + ["Z"] = { function() + require("spike.utils").zenmode(true) + end, "maximum zen" }, + ["qz"] = { function() + require("spike.utils").exitzen() + end, "exit zen" }, + ["zz"] = { function() + require("spike.utils").togglezen() + end, "toggle zen" }, -- option toggle cursor line ["l"] = { " set cul!", "toggle cursor line" }, + + ["c"] = { "ccloselclose", "close quickfix" }, ["d"] = { "DelayTrainToggle", "disable delay train" }, @@ -1122,9 +1151,20 @@ M.navigator = { M.refactoring = { plugin = true, - v = { - ["rr"] = {":lua require'refactoring'.select_refactor()", "refactoring using telescope", opts = { expr = false }}, - } + x = { + ["rr"] = { + function() + require('telescope').extensions.refactoring.refactors() + end, + "refactoring using telescope", opts = { expr = false }}, + }, + n = { + ["rr"] = { + function() + require('telescope').extensions.refactoring.refactors() + end, + "refactoring using telescope", opts = { expr = false }}, + }, } M.null_ls = { diff --git a/lua/spike/utils/init.lua b/lua/spike/utils/init.lua index 475697c..19991b0 100644 --- a/lua/spike/utils/init.lua +++ b/lua/spike/utils/init.lua @@ -1,5 +1,7 @@ local autocmd = vim.api.nvim_create_autocmd local api = vim.api +local opt = vim.opt +local g = vim.g local M = {} M["unload_lua_ns"] = function (prefix) @@ -86,6 +88,52 @@ M.lazy_load_module = function(patterns, plugin) }) end +M.togglezen = function() + if g.zenmode then + M.exitzen() + else + M.zenmode(true) + end +end + +--- disable all clutter from UI +---@param full? boolean maximum zen +M.zenmode = function(full) + opt.colorcolumn= '0' + opt.signcolumn = 'no' + g.indent_blankline_show_current_context = false + local ok, indent = pcall(require, "indent_blankline") + if ok then + indent.refresh() + end + opt.listchars:remove("eol") + opt.listchars:append("tab: ") + if full then + opt.number = false + opt.relativenumber = false + -- opt.listchars:append("tab: ") + -- opt.listchars:remove("eol") + opt.fillchars:append("eob: ") + end + g.zenmode = true +end + +--- cancel zenmode +M.exitzen = function() + opt.colorcolumn= '+0' + opt.signcolumn = 'yes' + g.indent_blankline_show_current_context = true + local ok, indent = pcall(require, "indent_blankline") + if ok then + indent.refresh() + end + opt.listchars:append("eol:↴") + opt.listchars:append("tab: ") + opt.number = true + opt.relativenumber = true + opt.fillchars:append("eob:∼") + g.zenmode = false +end return M From 660dd0c37bd14865a6db1507581003346b73b0fe Mon Sep 17 00:00:00 2001 From: blob42 Date: Sun, 6 Aug 2023 14:15:51 +0200 Subject: [PATCH 2/3] updated lsp navigator and diagnostics --- lua/custom/chadrc.lua | 2 +- lua/custom/plugins/configs/code-gpt.lua | 5 +++++ lua/custom/plugins/configs/navigator.lua | 19 ++++++++++++++----- lua/custom/plugins/configs/refactoring.lua | 2 ++ lua/custom/plugins/configs/todo-comments.lua | 1 + lua/custom/plugins/configs/treesitter.lua | 8 ++++---- lua/custom/plugins/init.lua | 1 + 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 4d4803b..28bbc22 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -33,7 +33,7 @@ M.ui = { diagnostic_head = '', -- default diagnostic head on dialogs diagnostic_err = '', -- severity 1 diagnostic_warn = '', -- 2 - diagnostic_info = '', -- 3 + diagnostic_info = '', -- 3 diagnostic_hint = '', -- 4 } }, diff --git a/lua/custom/plugins/configs/code-gpt.lua b/lua/custom/plugins/configs/code-gpt.lua index d398fb7..eb2ff75 100644 --- a/lua/custom/plugins/configs/code-gpt.lua +++ b/lua/custom/plugins/configs/code-gpt.lua @@ -13,6 +13,11 @@ M.setup = function() python = "Use pytest framework." } }, + ["code4"] = { + system_message_template = "You are a Programming pair Assistant AI. You are helpful with improving and optimizing source code using the best idiomatic practicies.", + model = "gpt-4", + user_message_template = "I have the following {{language}} code: ```{{filetype}}\n{{text_selection}}```\n{{command_args}}. {{language_instructions}} Think step by step then only return the code snippet and nothing else." + }, ["docu4"] = { system_message_template = "You are a technical documentation assistant to a software developer. You will help improving project documentation.", user_message_template = "Improve the following text: ```{{text_selection}}```\n. Use a professional. Write as if you are writing a python project documentation for a Github repo. {{command_args}}", diff --git a/lua/custom/plugins/configs/navigator.lua b/lua/custom/plugins/configs/navigator.lua index 4c9dcbe..64f6270 100644 --- a/lua/custom/plugins/configs/navigator.lua +++ b/lua/custom/plugins/configs/navigator.lua @@ -1,5 +1,6 @@ local present, navigator = pcall(require, "navigator") + if not present then return end @@ -18,6 +19,8 @@ local get_current_gomod = function() return mod_name end +-- default config +-- "~/.local/share/nvim/site/pack/packer/opt/navigator.lua/lua/navigator.lua" local config = { debug = false, transparency = 5, @@ -32,7 +35,8 @@ local config = { { key = 'gW', func = require('navigator.workspace').workspace_symbol_live, desc = 'lsp workspace_symbol_live' }, { key = '', func = require('navigator.definition').definition, desc = 'lsp definition' }, { key = 'gd', func = require('navigator.definition').definition, desc = 'lsp definition' }, - { key = 'gp', func = require('navigator.definition').definition_preview, desc = 'lsp definition_preview' }, + { key = 'gp', func = require('navigator.definition').definition_preview, desc = 'lsp definition preview' }, + { key = 'gP', func = require('navigator.definition').type_definition_preview, desc = 'lsp type definition preview' }, -- handled by main mappings -- { key = 'gt', func = require('navigator.treesitter').buf_ts, desc = 'lsp buf_ts' }, -- { key = 'gT', func = require('navigator.treesitter').bufs_ts, desc = 'lsp bufs_ts' }, @@ -97,7 +101,7 @@ local config = { icons = { icons = true, -- set to false to use system default ( if you using a terminal does not have nerd/icon) -- Code action - code_action_icon = ' ', -- "", + code_action_icon = '', -- "", -- code lens code_lens_action_icon = '', @@ -106,7 +110,7 @@ local config = { diagnostic_head = '', -- default diagnostic head on dialogs diagnostic_err = '', -- severity 1 diagnostic_warn = '', -- 2 - diagnostic_info = '', -- 3 + diagnostic_info = '', -- 3 diagnostic_hint = '', -- 4 -- used in the diagnostics summary window @@ -115,7 +119,7 @@ local config = { diagnostic_head_severity_3 = 'i', diagnostic_head_description = ' ', diagnostic_virtual_text = '', - diagnostic_file = '🚑', + diagnostic_file = ' ', -- Values -- @@ -143,7 +147,7 @@ local config = { module = '', flag = '', }, - treesitter_defult = '🌲', + treesitter_defult = '', doc_symbols = '', }, mason = true, @@ -162,6 +166,11 @@ local config = { severity_sort = { reverse = false }, }, + code_action = { + delay = 5000, -- 5 sec delay + virtual_text_icon = false, + }, + diagnostic_scrollbar_sign = false, display_diagnostic_qf = false, diff --git a/lua/custom/plugins/configs/refactoring.lua b/lua/custom/plugins/configs/refactoring.lua index 4e26b61..b62ff70 100644 --- a/lua/custom/plugins/configs/refactoring.lua +++ b/lua/custom/plugins/configs/refactoring.lua @@ -22,6 +22,8 @@ local config = { c = true, java = true, }, + printf_statements = {}, + print_var_statements = {}, } M.setup = function() diff --git a/lua/custom/plugins/configs/todo-comments.lua b/lua/custom/plugins/configs/todo-comments.lua index efcfe36..95b667d 100644 --- a/lua/custom/plugins/configs/todo-comments.lua +++ b/lua/custom/plugins/configs/todo-comments.lua @@ -16,6 +16,7 @@ local config = { WIP = { color = "default"}, NOTE = { alt = { "TIP", "INFO", "TRICK", "RELEASE"}}, DEBUG = {}, + REVIEW = { color = "info" } }, colors = { -- info = {"#2563EB"}, diff --git a/lua/custom/plugins/configs/treesitter.lua b/lua/custom/plugins/configs/treesitter.lua index b139e70..1a5fb9f 100644 --- a/lua/custom/plugins/configs/treesitter.lua +++ b/lua/custom/plugins/configs/treesitter.lua @@ -48,10 +48,10 @@ return { -- } -- }, -- - rainbow = { - enable = true, - extended_mode = true, - }, + -- rainbow = { + -- enable = true, + -- extended_mode = true, + -- }, textobjects = { enable = true, diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index c5833c1..6670bb2 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -132,6 +132,7 @@ return { -- Code Refactoring ["ThePrimeagen/refactoring.nvim"] = { + module = {"refactoring"}, setup = function() require("core.utils").load_mappings "refactoring" end, From 1e22939ada81616306f1e6ada014a7884e6fd91c Mon Sep 17 00:00:00 2001 From: blob42 Date: Mon, 7 Aug 2023 14:40:31 +0200 Subject: [PATCH 3/3] ui/ux enhancements --- after/plugin/theme.lua | 7 +++++- lua/core/mappings.lua | 9 ++++++++ lua/core/options.lua | 4 ++-- lua/custom/chadrc.lua | 8 +++---- lua/custom/highlights.lua | 12 +++++++---- lua/custom/plugins/configs/code-gpt.lua | 7 ++++-- lua/custom/plugins/configs/navigator.lua | 2 +- lua/custom/plugins/nvchadui.lua | 27 ++++++++++++++++++++++-- lua/spike/dap/dapmode.lua | 2 ++ lua/spike/utils/init.lua | 8 +++++-- 10 files changed, 68 insertions(+), 18 deletions(-) diff --git a/after/plugin/theme.lua b/after/plugin/theme.lua index 8497498..643b02c 100644 --- a/after/plugin/theme.lua +++ b/after/plugin/theme.lua @@ -20,7 +20,12 @@ local highlights = { St_file_sep_rev = { fg = colors.statusline_bg, bg = colors.lightbg, - } + }, + DiagnosticUnderlineError = { + fg = c.change_hex_lightness(colors["red"], 5), + underline = true, + }, + } function set_hl() diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 2e1e972..3fee900 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -172,6 +172,15 @@ M.general = { --{{{ }, + ["tT"] = { + function() + require("base46").toggle_transparency() + end, + "toggle transparency", + }, + + + -- luasnip edit snippets ["sne"] = { diff --git a/lua/core/options.lua b/lua/core/options.lua index b9c0ce9..3ed8733 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -25,7 +25,7 @@ opt.showmode = false opt.title = true opt.clipboard = "unnamed" -opt.cul = true -- cursor line +opt.cul = false -- cursor line -- opt.colorcolumn = "80" opt.colorcolumn = '+0' -- make colorcolumn follow text width opt.textwidth = 80 @@ -77,7 +77,7 @@ opt.foldlevelstart = 1 opt.conceallevel=1 -- how to show text with :syn-conceal syntax opt.list = true -- show tabs,trailing spaces and non-breakable spaces -opt.listchars = "tab: ,trail:,extends:#,nbsp:⋅,eol:↴" -- Highlight problematic whitespace +opt.listchars = "tab: ,trail:,extends:#,nbsp:⋅,eol:" -- Highlight problematic whitespace opt.diffopt:append("vertical") opt.completeopt = "menu,menuone,noselect" opt.wrap = false diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 28bbc22..fd832af 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -18,9 +18,9 @@ local highlights = require "custom.highlights" M.ui = { -- theme = "gruvbox_material", -- theme = "ayu-dark", - theme = "catppuccin", - theme_toggle = { "gruvbox_material", "gruvbox_light" }, - transparency = true, + theme = "chadracula", + theme_toggle = { "catppuccin", "chadracula"}, + -- transparency = true, hl_override = highlights.override, hl_add = highlights.add, -- hl_override = { @@ -31,7 +31,7 @@ M.ui = { myicons = { lsp = { diagnostic_head = '', -- default diagnostic head on dialogs - diagnostic_err = '', -- severity 1 + diagnostic_err = '', -- severity 1 diagnostic_warn = '', -- 2 diagnostic_info = '', -- 3 diagnostic_hint = '', -- 4 diff --git a/lua/custom/highlights.lua b/lua/custom/highlights.lua index 766dd14..0a57cb5 100644 --- a/lua/custom/highlights.lua +++ b/lua/custom/highlights.lua @@ -37,6 +37,9 @@ M.override = { St_LspInfo = { fg = "white" }, + St_LspStatus = { + fg = "sun" + }, LineNr = { fg = "#5f4468" }, @@ -65,10 +68,11 @@ M.add = { fg = "white", italic = true, }, - DiagnosticUnderlineError = { - fg = "black", - bg = "pink", - }, + -- Definied in custom theme parameters (after/plugin/theme.lua) + -- DiagnosticUnderlineError = { + -- fg = "red", + -- underline = true, + -- }, -- Code Lens related colors LspCodeLens = { fg = "vibrant_green", diff --git a/lua/custom/plugins/configs/code-gpt.lua b/lua/custom/plugins/configs/code-gpt.lua index eb2ff75..eba3d6a 100644 --- a/lua/custom/plugins/configs/code-gpt.lua +++ b/lua/custom/plugins/configs/code-gpt.lua @@ -19,8 +19,11 @@ M.setup = function() user_message_template = "I have the following {{language}} code: ```{{filetype}}\n{{text_selection}}```\n{{command_args}}. {{language_instructions}} Think step by step then only return the code snippet and nothing else." }, ["docu4"] = { - system_message_template = "You are a technical documentation assistant to a software developer. You will help improving project documentation.", - user_message_template = "Improve the following text: ```{{text_selection}}```\n. Use a professional. Write as if you are writing a python project documentation for a Github repo. {{command_args}}", + language_instructions = { + python = "Use docstings to document the code. This project uses Sphinx. Use the google style python docstrings. Add sphinx directives if needed." + }, + system_message_template = "You are a technical documentation assistant to a software developer. Help the user write clean detailed and easy to read project documentation.", + user_message_template = "Create or improve the documentation for: ```{{text_selection}}```\n. Use a professional tone. {{language_instructions}} {{command_args}}", model = "gpt-4" }, } diff --git a/lua/custom/plugins/configs/navigator.lua b/lua/custom/plugins/configs/navigator.lua index 64f6270..14cb82d 100644 --- a/lua/custom/plugins/configs/navigator.lua +++ b/lua/custom/plugins/configs/navigator.lua @@ -108,7 +108,7 @@ local config = { -- Diagnostics diagnostic_head = '', -- default diagnostic head on dialogs - diagnostic_err = '', -- severity 1 + diagnostic_err = '', -- severity 1 diagnostic_warn = '', -- 2 diagnostic_info = '', -- 3 diagnostic_hint = '', -- 4 diff --git a/lua/custom/plugins/nvchadui.lua b/lua/custom/plugins/nvchadui.lua index 96a7c8f..4679199 100644 --- a/lua/custom/plugins/nvchadui.lua +++ b/lua/custom/plugins/nvchadui.lua @@ -98,7 +98,11 @@ return { hints = (hints and hints > 0) and ("%#St_lspHints#" .. myicons.lsp.diagnostic_hint .. " " .. hints .. " ") or "" info = (info and info > 0) and ("%#St_lspInfo#" .. myicons.lsp.diagnostic_info .. " " .. info .. " ") or "" - return errors .. warnings .. hints .. info + if vim.o.columns > 120 then + return errors .. warnings .. hints .. info + else + return "" + end end, LSP_progress = function() @@ -134,7 +138,7 @@ return { if rawget(vim, "lsp") then for _, client in ipairs(vim.lsp.get_active_clients()) do if client.attached_buffers[vim.api.nvim_get_current_buf()] then - lsp_status = (vim.o.columns > 100 and "%#St_LspStatus#" .. "  [" .. client.name .. "] ") or "  " + lsp_status = (vim.o.columns > 100 and "%#St_LspStatus#" .. "[" .. client.name .. "]") or "%#St_LspStatus#" .. " " end end end @@ -164,6 +168,25 @@ return { text = '%l,%c%V%\\ %p%%' return "%#St_pos_text#" .. " " .. text .. " " + end, + + git = function() + if not vim.b.gitsigns_head or vim.b.gitsigns_git_status then + return "" + end + + local git_status = vim.b.gitsigns_status_dict + + local added = (git_status.added and git_status.added ~= 0) and ("  " .. git_status.added) or "" + local changed = (git_status.changed and git_status.changed ~= 0) and ("  " .. git_status.changed) or "" + local removed = (git_status.removed and git_status.removed ~= 0) and ("  " .. git_status.removed) or "" + local branch_name = "  " .. git_status.head .. " " + + if vim.o.columns > 120 then + return "%#St_gitIcons#" .. branch_name .. added .. changed .. removed + else + return "" + end end } diff --git a/lua/spike/dap/dapmode.lua b/lua/spike/dap/dapmode.lua index 60f6c38..57fb2d0 100644 --- a/lua/spike/dap/dapmode.lua +++ b/lua/spike/dap/dapmode.lua @@ -56,6 +56,8 @@ local config = { S = { rhs = function() daputils.disconnect_dap() + M.layer:exit() + vim.cmd("redrawstatus") end, desc = '[dap] stop' }, diff --git a/lua/spike/utils/init.lua b/lua/spike/utils/init.lua index 19991b0..bed9c7e 100644 --- a/lua/spike/utils/init.lua +++ b/lua/spike/utils/init.lua @@ -100,7 +100,6 @@ end ---@param full? boolean maximum zen M.zenmode = function(full) opt.colorcolumn= '0' - opt.signcolumn = 'no' g.indent_blankline_show_current_context = false local ok, indent = pcall(require, "indent_blankline") if ok then @@ -108,12 +107,15 @@ M.zenmode = function(full) end opt.listchars:remove("eol") opt.listchars:append("tab: ") + vim.cmd("TSDisable highlight") if full then + opt.signcolumn = 'no' opt.number = false opt.relativenumber = false -- opt.listchars:append("tab: ") -- opt.listchars:remove("eol") opt.fillchars:append("eob: ") + opt.cmdheight = 0 end g.zenmode = true end @@ -127,12 +129,14 @@ M.exitzen = function() if ok then indent.refresh() end - opt.listchars:append("eol:↴") + opt.listchars:append("eol:") opt.listchars:append("tab: ") opt.number = true opt.relativenumber = true opt.fillchars:append("eob:∼") + opt.cmdheight = 1 g.zenmode = false + vim.cmd("TSEnable highlight") end return M