mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
Merge pull request #112 from acicco/excluded_filetypes_option
feat: added excluded_filetypes option to avoid adding unwanted filety…
This commit is contained in:
commit
8ef4e87598
@ -146,6 +146,7 @@ require("harpoon").setup({
|
|||||||
save_on_toggle = false,
|
save_on_toggle = false,
|
||||||
save_on_change = true,
|
save_on_change = true,
|
||||||
enter_on_sendcmd = false,
|
enter_on_sendcmd = false,
|
||||||
|
excluded_filetypes = { "harpoon" }
|
||||||
},
|
},
|
||||||
... your other configs ...
|
... your other configs ...
|
||||||
})
|
})
|
||||||
@ -159,6 +160,7 @@ require("harpoon").setup({
|
|||||||
what I have found).
|
what I have found).
|
||||||
* `enter_on_sendcmd` will set harpoon to run the command immediately as it's
|
* `enter_on_sendcmd` will set harpoon to run the command immediately as it's
|
||||||
passed to the terminal when calling `sendCommand`.
|
passed to the terminal when calling `sendCommand`.
|
||||||
|
* `excluded_filetypes` filetypes that you want to prevent from adding to the harpoon list menu.
|
||||||
|
|
||||||
#### Preconfigured Terminal Commands
|
#### Preconfigured Terminal Commands
|
||||||
These are project specific commands that you wish to execute on the regular.
|
These are project specific commands that you wish to execute on the regular.
|
||||||
|
@ -157,6 +157,7 @@ M.setup = function(config)
|
|||||||
["save_on_toggle"] = false,
|
["save_on_toggle"] = false,
|
||||||
["save_on_change"] = true,
|
["save_on_change"] = true,
|
||||||
["enter_on_sendcmd"] = false,
|
["enter_on_sendcmd"] = false,
|
||||||
|
["excluded_filetypes"] = { "harpoon" },
|
||||||
},
|
},
|
||||||
}, expand_dir(
|
}, expand_dir(
|
||||||
c_config
|
c_config
|
||||||
|
@ -115,6 +115,27 @@ local function validate_buf_name(buf_name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function filter_filetype()
|
||||||
|
local current_filetype = vim.bo.filetype
|
||||||
|
local excluded_filetypes = harpoon.get_global_settings().excluded_filetypes
|
||||||
|
|
||||||
|
if current_filetype == "harpoon" then
|
||||||
|
log.error("filter_filetype(): You can't add harpoon to the harpoon")
|
||||||
|
error("You can't add harpoon to the harpoon")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.tbl_contains(excluded_filetypes, current_filetype) then
|
||||||
|
log.error(
|
||||||
|
'filter_filetype(): This filetype cannot be added or is included in the "excluded_filetypes" option'
|
||||||
|
)
|
||||||
|
error(
|
||||||
|
'This filetype cannot be added or is included in the "excluded_filetypes" option'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
M.get_index_of = function(item)
|
M.get_index_of = function(item)
|
||||||
log.trace("get_index_of():", item)
|
log.trace("get_index_of():", item)
|
||||||
if item == nil then
|
if item == nil then
|
||||||
@ -180,6 +201,7 @@ M.valid_index = function(idx)
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.add_file = function(file_name_or_buf_id)
|
M.add_file = function(file_name_or_buf_id)
|
||||||
|
filter_filetype()
|
||||||
local buf_name = get_buf_name(file_name_or_buf_id)
|
local buf_name = get_buf_name(file_name_or_buf_id)
|
||||||
log.trace("add_file():", buf_name)
|
log.trace("add_file():", buf_name)
|
||||||
|
|
||||||
@ -290,6 +312,7 @@ M.get_length = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.set_current_at = function(idx)
|
M.set_current_at = function(idx)
|
||||||
|
filter_filetype()
|
||||||
local buf_name = get_buf_name()
|
local buf_name = get_buf_name()
|
||||||
log.trace("set_current_at(): Setting id", idx, buf_name)
|
log.trace("set_current_at(): Setting id", idx, buf_name)
|
||||||
local config = harpoon.get_mark_config()
|
local config = harpoon.get_mark_config()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user