Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ed82177

Browse files
author
slavanorm
committed
tasf1-f4 keys k to buffer on load.
1 parent db5d7bd commit ed82177

File tree

6 files changed

+18
-53
lines changed

6 files changed

+18
-53
lines changed

lua/leetcode-ui/renderer/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ function Renderer:map(mode, key, handler, opts) --
9090
self._.keymaps[key] = mode
9191
end
9292
vim.keymap.set(mode, key, handler, options)
93-
vim.keymap.set(mode, key, handler, options)
9493
end
9594
end
9695

lua/leetcode-ui/renderer/menu.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,15 @@ function Menu:set_page(name)
122122
end
123123

124124
function Menu:apply_options()
125-
api.nvim_buf_set_name(self.bufnr, "")
125+
api.nvim_buf_set_name(self.bufnr, "Menu")
126126

127127
ui_utils.buf_set_opts(self.bufnr, {
128128
modifiable = false,
129-
buflisted = false,
130129
matchpairs = "",
131130
swapfile = false,
132-
buftype = "nofile",
133131
filetype = config.name,
134132
synmaxcol = 0,
133+
buftype = "nowrite",
135134
})
136135
ui_utils.win_set_opts(self.winid, {
137136
wrap = false,

lua/leetcode-ui/split/description.lua

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
local config = require("leetcode.config")
2-
local img_ok, image_api = pcall(require, "image")
3-
local img_sup = img_ok and config.user.image_support
42

53
local Group = require("leetcode-ui.group")
64
local Padding = require("leetcode-ui.lines.padding")
@@ -32,16 +30,17 @@ end
3230
function Description:mount()
3331
Description.super.mount(self)
3432
self:populate()
35-
33+
vim.api.nvim_buf_set_name(self.bufnr, "Task")
3634
local ui_utils = require("leetcode-ui.utils")
3735
ui_utils.buf_set_opts(self.bufnr, {
38-
modifiable = false,
3936
matchpairs = "",
4037
swapfile = false,
41-
buftype = "nofile",
4238
filetype = "markdown",
4339
synmaxcol = 0,
40+
buflisted = true,
41+
bufhidden = "hide",
4442
})
43+
--[[
4544
ui_utils.win_set_opts(self.winid, {
4645
wrap = true,
4746
colorcolumn = "",
@@ -56,50 +55,14 @@ function Description:mount()
5655
signcolumn = "no",
5756
linebreak = true,
5857
})
59-
if not img_ok and config.user.image_support then
60-
log.error("image.nvim not found but `image_support` is enabled")
61-
end
62-
58+
--]]
6359
self:draw()
6460
self:autocmds()
6561
return self
6662
end
6763

6864
function Description:draw()
6965
Description.super.draw(self)
70-
self:draw_imgs()
71-
end
72-
73-
function Description:draw_imgs()
74-
if not img_sup then
75-
return
76-
end
77-
78-
local lines = vim.api.nvim_buf_get_lines(self.bufnr, 1, -1, false)
79-
for i, line in ipairs(lines) do
80-
for link in line:gmatch("%((http[s]?://%S+)%)") do
81-
local img = self.images[link]
82-
83-
if not img then
84-
self.images[link] = {}
85-
86-
image_api.from_url(link, {
87-
buffer = self.bufnr,
88-
window = self.winid,
89-
with_virtual_padding = true,
90-
}, function(image)
91-
if not image then
92-
return
93-
end
94-
95-
self.images[link] = image
96-
image:render({ y = i + 1 })
97-
end)
98-
elseif not vim.tbl_isempty(img) then
99-
img:clear(true)
100-
end
101-
end
102-
end
10366
end
10467

10568
function Description:toggle_stats()

lua/leetcode-ui/split/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ function Split:update_renderer()
9090
self.renderer.winid = self.winid
9191
end
9292

93-
function Split:init(opts) --
94-
local options = vim.tbl_deep_extend("force", {
93+
function Split:init(opts)
94+
local options = vim.tbl_deep_extend("force", {
9595
relative = "editor",
9696
enter = false,
9797
focusable = true,

lua/leetcode/command/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ function cmd.qot()
138138
end
139139
local problemlist = require("leetcode.cache.problemlist")
140140
Question(problemlist.get_by_title_slug(qot.title_slug)):mount()
141+
cmd.desc_toggle()
142+
141143
end)
142144
end
143145

lua/leetcode/config/template.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ local M = {
100100

101101
width = "40%", ---@type lc.size
102102

103-
show_stats = true, ---@type boolean
103+
show_stats = false, ---@type boolean
104104
},
105105

106106
---@type lc.picker
107107
picker = { provider = nil },
108-
109108
hooks = {
110109
---@type fun()[]
111110
["enter"] = {},
@@ -118,17 +117,20 @@ local M = {
118117
},
119118

120119
keys = {
121-
toggle = { "q" }, ---@type string|string[]
122-
confirm = { "<CR>" }, ---@type string|string[]
120+
toggle = { "x" }, ---@type string|string[]
121+
confirm = {}, ---@type string|string[]
123122

124123
reset_testcases = "r", ---@type string
125124
use_testcase = "U", ---@type string
126125
focus_testcases = "H", ---@type string
127126
focus_result = "L", ---@type string
128127
},
129-
130128
---@type boolean
131129
image_support = false,
132130
}
131+
vim.keymap.set({"n","v","x"},'<F1>',":Leet console<CR>" , {noremap=true,silent=true})
132+
vim.keymap.set({"n","v","x"},'<F2>',":Leet test<CR>" , {noremap=true,silent=true})
133+
vim.keymap.set({"n","v","x"},'<F3>',":Leet submit<CR>", {noremap=true,silent=true})
134+
vim.keymap.set({"n","v","x"},'<F4>',":Leet menu<CR>", {noremap=true,silent=true})
133135

134136
return M

0 commit comments

Comments
 (0)