Skip to content

Commit

Permalink
chore: QOL fixes & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinm6 committed Jan 6, 2025
1 parent 23da257 commit b350b62
Show file tree
Hide file tree
Showing 16 changed files with 521 additions and 537 deletions.
20 changes: 10 additions & 10 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" },
"image.nvim": { "branch": "master", "commit": "b991fc7f845bc6ab40c6ec00b39750dcd5190010" },
"jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
"lazy.nvim": { "branch": "main", "commit": "72aa3a2624be5dc240646084f7b6a38eb99eb2ce" },
"lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" },
"markdown.nvim": { "branch": "main", "commit": "1faa6568eb61467d64c3d0aad8ac4c9c0e45514e" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" },
"markdown.nvim": { "branch": "main", "commit": "16369540a005ad0cf267498162aedca6dfca1b9c" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.icons": { "branch": "main", "commit": "6787321f70d674a481776b7cc2c781fb7002c644" },
"mini.icons": { "branch": "main", "commit": "1c79feb7478ca773fa3dac5cadf43ced9180e861" },
"mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" },
"mini.surround": { "branch": "main", "commit": "aa5e245829dd12d8ff0c96ef11da28681d6049aa" },
"molten-nvim": { "branch": "main", "commit": "c621baf53459a6c45dfd98dcc11cbba7a7ae9470" },
Expand All @@ -25,15 +25,15 @@
"nvim-dap-ui": { "branch": "master", "commit": "e94d98649dccb6a3884b66aabc2e07beb279e535" },
"nvim-dbee": { "branch": "master", "commit": "21d2cc0844a16262bb6ea93ab3d0a0f20bd87853" },
"nvim-jdtls": { "branch": "master", "commit": "266d0cb912bbe61d66b43c5e73db19a364380360" },
"nvim-lint": { "branch": "master", "commit": "1fea92f1d9908eaa5eb8bafe08b4293d7aadaa55" },
"nvim-lspconfig": { "branch": "master", "commit": "a8ef5e6e497b3ebeaaf35b939c07c211563b2e05" },
"nvim-lint": { "branch": "master", "commit": "139cd3ccefdc92644746168dd95a15f36aec5458" },
"nvim-lspconfig": { "branch": "master", "commit": "8121483b8132b7053120fafd83728178fb3febf6" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-notify": { "branch": "master", "commit": "bd9cd51f9ef2f6326fc2bc9931d0718c1794e247" },
"nvim-treesitter": { "branch": "master", "commit": "fae21737be2846a04ae06a41d70b7fc8ad4bf9eb" },
"nvim-treesitter": { "branch": "master", "commit": "958af94dd8d74071c72c9d6840b41d06ea436b2f" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "d8b74fa87afc6a1e97b18da23e762efb032dc270" },
"nvim-ufo": { "branch": "main", "commit": "32cb247b893a384f1888b9cd737264159ecf183c" },
"obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" },
"oil.nvim": { "branch": "master", "commit": "c6a39a69b2df7c10466f150dde0bd23e49c1fba3" },
"oil.nvim": { "branch": "master", "commit": "c12fad2d225d8f81fadd48521d253607fe25465c" },
"otter.nvim": { "branch": "main", "commit": "e8c662e1aefa8b483cfba6e00729a39a363dcecc" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
Expand All @@ -42,6 +42,6 @@
"telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" },
"vimtex": { "branch": "master", "commit": "56def42c4f3007979c38001518ebb92ea8fb5f72" },
"which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }
"vimtex": { "branch": "master", "commit": "99c56940cefe6adead7500f7657cd6721ff38d05" },
"which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" }
}
29 changes: 18 additions & 11 deletions lua/lib/env.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

local env = {}

local has_tele, pickers = pcall(require, "telescope.pickers")

local function prepare_environment_variables()
local items = {}
for key, value in pairs(vim.fn.environ()) do
Expand All @@ -17,18 +15,12 @@ local function prepare_environment_variables()
return items
end

if not has_tele then
vim.print(prepare_environment_variables())
return
end

local finders = require "telescope.finders"
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
local entry_display = require "telescope.pickers.entry_display"
local conf = require("telescope.config").values

local function append_environment_name(prompt_bufnr)
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"

local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
if selection.value == "" then
Expand All @@ -40,6 +32,9 @@ local function append_environment_name(prompt_bufnr)
end

local function append_environment_value(prompt_bufnr)
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"

local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
if selection.value == "" then
Expand All @@ -51,6 +46,8 @@ local function append_environment_value(prompt_bufnr)
end

local function edit_environment_value(prompt_bufnr)
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)

Expand All @@ -68,6 +65,15 @@ local function edit_environment_value(prompt_bufnr)
end

local function show_environment_variables(opts)
local has_tele, pickers = pcall(require, "telescope.pickers")
if not has_tele then
vim.print(prepare_environment_variables())
return
end

local finders = require "telescope.finders"
local actions = require "telescope.actions"

opts = opts or {}
pickers
.new(opts, {
Expand All @@ -89,6 +95,7 @@ local function show_environment_variables(opts)
local env_name_width = math.floor(columns * 0.05)
local env_value_width = 22

local entry_display = require "telescope.pickers.entry_display"
-- NOTE: the width calculating logic is not exact, but approx enough
local displayer = entry_display.create {
separator = "",
Expand Down
3 changes: 1 addition & 2 deletions lua/lib/notes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
local note = {}

---Get available notes
---@private
---@return table
local function get_notes()
local notes = {}
Expand Down Expand Up @@ -75,4 +74,4 @@ function note.open_note()
end
end

return note
return note
9 changes: 4 additions & 5 deletions lua/lib/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ local session = {
}

---Get available sessions
---@private
---@return table
local function get_sessions()
local sessions = {}
Expand All @@ -28,7 +27,7 @@ local function delete_session()
local sessions = get_sessions()

if #sessions >= 1 then
require "telescope"
pcall(require, "telescope")
vim.ui.select(sessions, {
prompt = "Select session to delete:",
default = nil,
Expand All @@ -53,7 +52,7 @@ local function restore_session()
local sessions = get_sessions()

if #sessions >= 1 then
require "telescope"
pcall(require, "telescope")
vim.ui.select(sessions, {
prompt = " > Select session to restore",
format_item = function(item)
Expand All @@ -78,7 +77,7 @@ end
--- The session is saved into 'data' stdpath of nvim
---@see mksession |:mksession|
local function save_session()
require "telescope"
pcall(require, "telescope")
vim.ui.input({
prompt = "Enter session name: ",
default = nil,
Expand Down Expand Up @@ -113,4 +112,4 @@ function session.select(arg)
end
end

return session
return session
2 changes: 1 addition & 1 deletion lua/lib/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function M.new_terminal_win(cmd, autoclose, opts)
if opts.preset then
opts = M.presets[opts.preset]
end
local buf = vim.api.nvim_create_buf(false, false)
local buf = vim.api.nvim_create_buf(not autoclose, false) -- if autoclose -> buf = not listed
local width = opts.width or nil
local height = opts.height or nil
local rows = opts.relative and math.ceil(vim.o.lines - height) * 0.5 - 1 or nil
Expand Down
14 changes: 8 additions & 6 deletions lua/lib/ui/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,12 @@ end
local function get_lsp_progress()
local lsp = vim.lsp.status()
if lsp then
lsp = lsp:gsub(":", " ")
lsp = lsp:gsub("(%d+%%)", "%1%%") -- sanitize percentage
lsp = lsp:gsub("%s+", " ")
return lsp
vim.print(lsp)
-- sanitize percentage
lsp = vim.fn.fnameescape(lsp)
-- lsp = lsp:gsub(":", " "):gsub("(%d+%%)", "%1%%"):gsub("%s+", " ")

return (#lsp > 40) and string.sub(lsp, 1, 38) .. "" or lsp
end

return ""
Expand Down Expand Up @@ -433,7 +435,7 @@ local function enable_statusline()
"",
sl.colors.empty,
session_name(),
get_lsp_progress(),
-- get_lsp_progress(),
get_python_env(),

-- Middle
Expand Down Expand Up @@ -486,7 +488,7 @@ function sl.toggle()
"FileType",
"FileChangedShellPost",
"DiagnosticChanged",
"LspProgress",
-- "LspProgress",
}, {
group = vim.api.nvim_create_augroup("_statusline", { clear = true }),
callback = function(cb)
Expand Down
18 changes: 11 additions & 7 deletions lua/plugins/editor/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ return {
},

sources = {
default = { "snippets", "lsp", "path", "buffer", "lazydev" },
default = { "snippets", "lsp", "path", "buffer", "markdown", "lazydev" },
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
snippets = {
opts = {
extended_filetypes = {
Expand All @@ -50,6 +45,15 @@ return {
},
},
},
markdown = {
name = "RenderMarkdown",
module = "render-markdown.integ.blink",
},
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
},
min_keyword_length = function(ctx)
return ctx.mode == "cmdline" and 2 or 0
Expand Down Expand Up @@ -111,4 +115,4 @@ return {
ghost_text = { enabled = true },
},
},
}
}
4 changes: 2 additions & 2 deletions lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ local M = {
---LaTeX
{
"lervag/vimtex",
ft = { "tex", "plaintex" },
ft = { "tex", "plaintex", "bib" },
config = function()
vim.g.vimtex_view_method = "sioyek"
vim.g.vimtex_quickfix_mode = 0 -- don't open qflist on compile errors
Expand Down Expand Up @@ -406,4 +406,4 @@ local M = {
},
}

return M
return M
16 changes: 15 additions & 1 deletion lua/plugins/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,20 @@ return {
},
}))
end,

texlab = function()
lspconfig.texlab.setup(vim.tbl_deep_extend("force", default_lsp_config, {
settings = {
texlab = {
auxDirectory = string.format(
"%s/vimtex/aux_dir/%s",
vim.fn.stdpath "cache",
vim.fs.basename(vim.api.nvim_buf_get_name(0))
),
},
},
}))
end,
}
end,
},
Expand Down Expand Up @@ -695,4 +709,4 @@ return {
capabilities = init_capabilities,
on_init = custom_init,
on_attach = custom_attach,
}
}
8 changes: 4 additions & 4 deletions lua/plugins/ui/noice.lua → lua/plugins/ui/notifications.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
----------------------------------------
-- File : noice.lua
-- Description : noice plugin configuration
-- File : notifications.lua
-- Description : notifications plugins config
-- Author : Kevin
-- Last Modified: 26 Dec 2024, 11:05
-- Last Modified: 06/01/2025 - 10:19
----------------------------------------

return {
Expand Down Expand Up @@ -44,4 +44,4 @@ return {
vim.notify = notify
end,
},
}
}
17 changes: 14 additions & 3 deletions plugin/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,16 @@ autocmd("FileType", {

---Templates
autocmd("BufNewFile", {
group = vim.api.nvim_create_augroup("templates", { clear = true }),
group = augroup("templates", { clear = true }),
desc = "Load template file",
pattern = "*",
pattern = { "pom.xml", "*.md", "*.sh" },
callback = function(args)
local path = vim.fn.stdpath "config"
local fname = vim.fn.fnamemodify(args.file, ":t")
local ext = vim.fn.fnamemodify(args.file, ":e")
local candidates = { fname, ext }
local uv = vim.uv
vim.print(candidates)
-- vim.print(candidates)
for _, candidate in ipairs(candidates) do
local tmpl = table.concat { path, "/templates/", candidate, ".tpl" }
if uv.fs_stat(tmpl) then
Expand All @@ -325,3 +325,14 @@ autocmd("BufNewFile", {
end
end,
})

---Lsp progress
autocmd("LspProgress", {
group = augroup("_lsp_progress", { clear = true }),
callback = function()
local lsp = vim.lsp.status()
if lsp then
print(lsp)
end
end,
})
4 changes: 3 additions & 1 deletion plugin/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ nmap {
function()
local height = math.floor(vim.o.lines * 0.25)
require("lib.terminal").new_terminal_win("", true, {
listed = true,
height = height,
win = -1,
split = "below",
Expand All @@ -254,6 +255,7 @@ nmap {
function()
local width = math.floor(vim.o.columns * 0.4)
require("lib.terminal").new_terminal_win("", true, {
listed = true,
width = width,
win = -1,
split = "right",
Expand Down Expand Up @@ -498,4 +500,4 @@ vim.cmd.cnoreabbrev("XA", "xa")
-- end
-- end,
-- { desc = "Snippet jump backwards" },
-- }
-- }
2 changes: 1 addition & 1 deletion snippets/general/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"body": ["${CURRENT_HOUR}:${CURRENT_MINUTE}"],
"description": "Timestamp"
}
}
}
Loading

0 comments on commit b350b62

Please sign in to comment.