Skip to content

Commit

Permalink
chore(neovim): formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Nov 21, 2023
1 parent 0514907 commit f531790
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 36 deletions.
50 changes: 39 additions & 11 deletions .config/nvim/lua/plugins/coding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,37 @@ return {
keymaps = {
{
"<LocalLeader>re",
function() require("telescope").extensions.refactoring.refactors() end,
function()
require("telescope").extensions.refactoring.refactors()
end,
description = "Open Refactoring.nvim",
mode = { "n", "v", "x" },
},
{
"<LocalLeader>rd",
function() require("refactoring").debug.printf({ below = false }) end,
function()
require("refactoring").debug.printf({ below = false })
end,
description = "Insert Printf statement for debugging",
},
{
"<LocalLeader>rv",
{
n = function() require("refactoring").debug.print_var({ normal = true }) end,
x = function() require("refactoring").debug.print_var({}) end,
n = function()
require("refactoring").debug.print_var({ normal = true })
end,
x = function()
require("refactoring").debug.print_var({})
end,
},
description = "Insert Print_Var statement for debugging",
mode = { "n", "v" },
},
{
"<LocalLeader>rc",
function() require("refactoring").debug.cleanup() end,
function()
require("refactoring").debug.cleanup()
end,
description = "Cleanup debug statements",
},
},
Expand All @@ -68,19 +78,25 @@ return {
keys = {
{
"<C-a>",
function() require("copilot.suggestion").accept() end,
function()
require("copilot.suggestion").accept()
end,
desc = "Copilot: Accept suggestion",
mode = { "i" },
},
{
"<C-x>",
function() require("copilot.suggestion").dismiss() end,
function()
require("copilot.suggestion").dismiss()
end,
desc = "Copilot: Dismiss suggestion",
mode = { "i" },
},
{
"<C-\\>",
function() require("copilot.panel").open() end,
function()
require("copilot.panel").open()
end,
desc = "Copilot: Show Copilot panel",
mode = { "n", "i" },
},
Expand All @@ -89,7 +105,9 @@ return {
require("legendary").commands({
{
":CopilotToggle",
function() require("copilot.suggestion").toggle_auto_trigger() end,
function()
require("copilot.suggestion").toggle_auto_trigger()
end,
description = "Copilot: Toggle on/off for buffer",
},
})
Expand All @@ -114,6 +132,7 @@ return {
"theHamsta/nvim-dap-virtual-text", -- help to find variable definitions in debug mode
"rcarriga/nvim-dap-ui", -- Nice UI for nvim-dap
"suketa/nvim-dap-ruby", -- Debug Ruby
"mfussenegger/nvim-dap-python", -- Debug Python
},
init = function()
require("legendary").keymaps({
Expand Down Expand Up @@ -152,12 +171,15 @@ return {
config = function()
local dap = require("dap")
require("dap-ruby").setup()
require("dap-python").setup("~/.virtualenvs/debugpy/bin/python")

---Show the nice virtual text when debugging
---@return nil|function
local function virtual_text_setup()
local ok, virtual_text = om.safe_require("nvim-dap-virtual-text")
if not ok then return end
if not ok then
return
end

return virtual_text.setup()
end
Expand All @@ -184,7 +206,9 @@ return {
---@return nil
local function ui_setup(adapter)
local ok, dapui = om.safe_require("dapui")
if not ok then return end
if not ok then
return
end

dapui.setup({
layouts = {
Expand Down Expand Up @@ -283,6 +307,7 @@ return {

-- Adapters
"nvim-neotest/neotest-plenary",
"nvim-neotest/neotest-python",
"olimorris/neotest-rspec",
"olimorris/neotest-phpunit",
},
Expand Down Expand Up @@ -324,6 +349,9 @@ return {
require("neotest").setup({
adapters = {
require("neotest-plenary"),
require("neotest-python")({
dap = { justMyCode = false },
}),
require("neotest-rspec"),
require("neotest-phpunit"),
},
Expand Down
96 changes: 72 additions & 24 deletions .config/nvim/lua/plugins/heirline/statuscolumn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ M.static = {
mousepos = vim.fn.getmousepos(),
}
local sign = vim.fn.screenstring(args.mousepos.screenrow, args.mousepos.screencol)
if sign == " " then sign = vim.fn.screenstring(args.mousepos.screenrow, args.mousepos.screencol - 1) end
if sign == " " then
sign = vim.fn.screenstring(args.mousepos.screenrow, args.mousepos.screencol - 1)
end
args.sign = self.signs[sign]
vim.api.nvim_set_current_win(args.mousepos.winid)
vim.api.nvim_win_set_cursor(0, { args.mousepos.line, 0 })
Expand All @@ -26,20 +28,28 @@ M.static = {
M.init = function(self)
self.signs = {}

self.handlers.signs = function(args) return vim.schedule(vim.diagnostic.open_float) end
self.handlers.signs = function(args)
return vim.schedule(vim.diagnostic.open_float)
end

self.handlers.line_number = function(args)
local dap_avail, dap = pcall(require, "dap")
if dap_avail then vim.schedule(dap.toggle_breakpoint) end
if dap_avail then
vim.schedule(dap.toggle_breakpoint)
end
end

self.handlers.git_signs = function(args)
if gitsigns_avail then vim.schedule(gitsigns.preview_hunk) end
if gitsigns_avail then
vim.schedule(gitsigns.preview_hunk)
end
end

self.handlers.fold = function(args)
local lnum = args.mousepos.line
if vim.fn.foldlevel(lnum) <= vim.fn.foldlevel(lnum - 1) then return end
if vim.fn.foldlevel(lnum) <= vim.fn.foldlevel(lnum - 1) then
return
end
vim.cmd.execute("'" .. lnum .. "fold" .. (vim.fn.foldclosed(lnum) == -1 and "close" or "open") .. "'")
end
end
Expand All @@ -59,7 +69,9 @@ M.signs = {
end

-- Filter out git signs
signs = vim.tbl_filter(function(sign) return not vim.startswith(sign.group, "gitsigns") end, signs[1].signs)
signs = vim.tbl_filter(function(sign)
return not vim.startswith(sign.group, "gitsigns")
end, signs[1].signs)

if #signs == 0 then
self.sign = nil
Expand All @@ -70,16 +82,24 @@ M.signs = {
self.has_sign = self.sign ~= nil
end,
provider = function(self)
if self.has_sign then return vim.fn.sign_getdefined(self.sign.name)[1].text end
if self.has_sign then
return vim.fn.sign_getdefined(self.sign.name)[1].text
end
return " "
end,
hl = function(self)
if self.has_sign then
-- Neotest signs
if self.sign.group == "neotest-status" then
if self.sign.name == "neotest_running" then return "NeotestRunning" end
if self.sign.name == "neotest_failed" then return "NeotestFailed" end
if self.sign.name == "neotest_passed" then return "NeotestPassed" end
if self.sign.name == "neotest_running" then
return "NeotestRunning"
end
if self.sign.name == "neotest_failed" then
return "NeotestFailed"
end
if self.sign.name == "neotest_passed" then
return "NeotestPassed"
end
return "NeotestSkipped"
end

Expand All @@ -91,67 +111,91 @@ M.signs = {
on_click = {
name = "sign_click",
callback = function(self, ...)
if self.handlers.signs then self.handlers.signs(self.click_args(self, ...)) end
if self.handlers.signs then
self.handlers.signs(self.click_args(self, ...))
end
end,
},
}

M.line_numbers = {
provider = function()
if vim.v.virtnum ~= 0 then return "" end
if vim.v.virtnum ~= 0 then
return ""
end

if vim.v.relnum == 0 then return vim.v.lnum end
if vim.v.relnum == 0 then
return vim.v.lnum
end

return vim.v.relnum
end,
on_click = {
name = "line_number_click",
callback = function(self, ...)
if self.handlers.line_number then self.handlers.line_number(self.click_args(self, ...)) end
if self.handlers.line_number then
self.handlers.line_number(self.click_args(self, ...))
end
end,
},
}

M.folds = {
condition = function() return vim.v.virtnum == 0 end,
condition = function()
return vim.v.virtnum == 0
end,
init = function(self)
self.lnum = vim.v.lnum
self.folded = vim.fn.foldlevel(self.lnum) > vim.fn.foldlevel(self.lnum - 1)
end,
{
condition = function(self) return self.folded end,
condition = function(self)
return self.folded
end,
{
provider = function(self)
if vim.fn.foldclosed(self.lnum) == -1 then return "" end
if vim.fn.foldclosed(self.lnum) == -1 then
return ""
end
end,
},
{
provider = function(self)
if vim.fn.foldclosed(self.lnum) ~= -1 then return "" end
if vim.fn.foldclosed(self.lnum) ~= -1 then
return ""
end
end,
hl = { fg = "yellow" },
},
},
{
condition = function(self) return not self.folded end,
condition = function(self)
return not self.folded
end,
provider = " ",
},
on_click = {
name = "fold_click",
callback = function(self, ...)
if self.handlers.fold then self.handlers.fold(self.click_args(self, ...)) end
if self.handlers.fold then
self.handlers.fold(self.click_args(self, ...))
end
end,
},
}

M.git_signs = {
{
condition = function() return not conditions.is_git_repo() or vim.v.virtnum ~= 0 end,
condition = function()
return not conditions.is_git_repo() or vim.v.virtnum ~= 0
end,
provider = "",
hl = "HeirlineStatusColumn",
},
{
condition = function() return conditions.is_git_repo() and vim.v.virtnum == 0 end,
condition = function()
return conditions.is_git_repo() and vim.v.virtnum == 0
end,
init = function(self)
local signs = vim.fn.sign_getplaced(vim.api.nvim_get_current_buf(), {
group = "gitsigns_vimfn_signs_",
Expand All @@ -169,13 +213,17 @@ M.git_signs = {
end,
provider = "",
hl = function(self)
if self.has_sign then return self.sign.name end
if self.has_sign then
return self.sign.name
end
return "HeirlineStatusColumn"
end,
on_click = {
name = "gitsigns_click",
callback = function(self, ...)
if self.handlers.git_signs then self.handlers.git_signs(self.click_args(self, ...)) end
if self.handlers.git_signs then
self.handlers.git_signs(self.click_args(self, ...))
end
end,
},
},
Expand Down
2 changes: 1 addition & 1 deletion .config/nvim/lua/plugins/utilities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ return {
include_legendary_cmds = false,
extensions = {
lazy_nvim = false,
which_key = false
which_key = false,
},
-- Load these with the plugin to ensure they are loaded before any Neovim events
autocmds = require("config.autocmds"),
Expand Down

0 comments on commit f531790

Please sign in to comment.