Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim.opt_local in ftplugin is not set correctly when opening files using harpoon #626

Open
chenxin-yan opened this issue Aug 7, 2024 · 4 comments

Comments

@chenxin-yan
Copy link

chenxin-yan commented Aug 7, 2024

I use ftpluign/markdown.md to set text wrap to true when opening a markdown file. It works as expected. However, when openning markdown file for the first time on startup using harpoon, text wrap is not set to true.

-- Text wrap
vim.opt_local.wrap = true -- Wrap text
vim.opt_local.linebreak = true -- Line break on whole words

here is my config

@GusJelly
Copy link

GusJelly commented Sep 3, 2024

This happens with any code that you write that is specific to filetypes. Even when I use autocmds for filetypes, navigating to a file using harpoon (either with the gui or list:select()) makes it so neovim does not use filetype specific code. I think this is only happening on filetypes, since using an autocmd with BufEnter makes it so that it works normally.

@chenxin-yan
Copy link
Author

I see, Is there any way arround this, such as specify a callback function when switching files using Harpoon?

@GusJelly
Copy link

GusJelly commented Sep 5, 2024

I see, Is there any way around this, such as specify a callback function when switching files using Harpoon?

I couldn't find a way around it. I went back to old harpoon since it doesn't have this issue.

@dhzip
Copy link

dhzip commented Sep 23, 2024

If you don't mind a band-aid job, you can have an autocmd source your ftplugin files without much pain.

vim.api.nvim_create_autocmd({ "BufEnter" }, {
  desc     = "Source ftplugin/$1.lua to override Issue #626",
  group    = vim.api.nvim_create_augroup("Harpoon_Optlocal", { clear = true }),
  callback = function()
    local ft = vim.bo.filetype
    vim.cmd("silent! source $XDG_CONFIG_HOME/nvim/after/ftplugin/" .. ft .. ".lua")
  end,
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants