fix: some basic fixes for buffer type

This commit is contained in:
mpaulson 2023-12-10 12:49:40 -07:00
parent a31438258a
commit 5a3195e7bf
3 changed files with 23 additions and 41 deletions

View File

@ -49,50 +49,26 @@ function M.setup_autocmds_and_keymaps(bufnr)
end end
vim.api.nvim_buf_set_option(bufnr, "filetype", "harpoon") vim.api.nvim_buf_set_option(bufnr, "filetype", "harpoon")
vim.api.nvim_buf_set_option(bufnr, "buftype", "acwrite") vim.keymap.set(
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "delete")
vim.api.nvim_buf_set_keymap(
bufnr,
"n", "n",
"q", "q",
"<Cmd>lua require('harpoon.buffer').run_toggle_command('q')<CR>", function() M.run_toggle_command("q") end,
{ silent = true } { buffer = bufnr, silent = true }
)
vim.api.nvim_buf_set_keymap(
bufnr,
"n",
"<ESC>",
"<Cmd>lua require('harpoon.buffer').run_toggle_command('Esc')<CR>",
{ silent = true }
)
vim.api.nvim_buf_set_keymap(
bufnr,
"n",
"<CR>",
"<Cmd>lua require('harpoon.buffer').run_select_command()<CR>",
{}
) )
-- TODO: Do we want this? is this a thing? vim.keymap.set(
-- its odd... why save on text change? shouldn't we wait until close / w / esc? "n",
--[[ "<Esc>",
if global_config.save_on_change then function() M.run_toggle_command("Esc") end,
vim.cmd( { buffer = bufnr, silent = true }
string.format( )
"autocmd TextChanged,TextChangedI <buffer=%s> lua require('harpoon').ui:save()",
bufnr vim.keymap.set(
) "n",
) "<CR>",
end function() M.run_select_command() end,
--]] { buffer = bufnr, silent = true }
vim.api.nvim_create_autocmd("BufModifiedSet", { )
buffer = bufnr,
group = HarpoonGroup,
callback = function()
vim.api.nvim_buf_set_option(bufnr, "modified", false)
end,
})
vim.api.nvim_create_autocmd({ "BufWriteCmd" }, { vim.api.nvim_create_autocmd({ "BufWriteCmd" }, {
group = HarpoonGroup, group = HarpoonGroup,

View File

@ -5,6 +5,11 @@ local harpoon = require("harpoon")
local eq = assert.are.same local eq = assert.are.same
local be = utils.before_each(os.tmpname()) local be = utils.before_each(os.tmpname())
local function key(k)
k = vim.api.nvim_replace_termcodes(k, true, false, true)
vim.api.nvim_feedkeys(k, "m", false)
end
describe("harpoon", function() describe("harpoon", function()
before_each(function() before_each(function()
be() be()

View File

@ -82,7 +82,8 @@ function HarpoonUI:_create_window()
local height = 8 local height = 8
local borderchars = self.settings.border_chars local borderchars = self.settings.border_chars
local bufnr = vim.api.nvim_create_buf(false, false) local bufnr = vim.api.nvim_create_buf(false, true)
-- TODO: Remove popup and just use nvim_open_win
local _, popup_info = popup.create(bufnr, { local _, popup_info = popup.create(bufnr, {
title = "Harpoon", title = "Harpoon",
highlight = "HarpoonWindow", highlight = "HarpoonWindow",