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

Templates plugin on Neovim #140

Open
antoinekahlouche opened this issue Nov 18, 2023 · 4 comments
Open

Templates plugin on Neovim #140

antoinekahlouche opened this issue Nov 18, 2023 · 4 comments

Comments

@antoinekahlouche
Copy link

I have troubles using the "rust-sailfish/sailfish" plugin.

I’m using Packer on Neovim :
use 'rust-sailfish/sailfish'
I checked and the package is installed
but when I access a .stpl file, my :LspInfo doesn’t recognize the filetype.
So the plugin is not loaded.

My LSP plugins are 'VonHeikemen/lsp-zero.nvim' with 'neovim/nvim-lspconfig'

I’m pretty sure I miss a step, can someone help me ?

@gengjun
Copy link

gengjun commented Nov 22, 2023

That plugin is not working for me, I just put this code to my lua vim config, it force nvim think .stpl is .html file

local autocmd = vim.api.nvim_create_autocmd
autocmd({
	"BufNewFile",
	"BufRead",
}, {
	pattern = "*.stpl",
	callback = function()
		if vim.fn.search("{{.\\+}}", "nw") ~= 0 then
			local buf = vim.api.nvim_get_current_buf()
			vim.api.nvim_buf_set_option(buf, "filetype", "html")
		end
	end,
})

@antoinekahlouche
Copy link
Author

@gengjun thanks for your answer

I have no problem with Neovim detecting the HTML part, I think, with my setup, if it doesn't know the extension it looks inside and infers the language.

And if you want to enforce it, you can do something simpler :

vim.filetype.add({
    extension = {
        stpl = 'html',
    }
})

My problem is that the Rust part of my templates is not detected as Rust code.
So I was hoping this plugin would help me

@antoinekahlouche
Copy link
Author

I stumbled upon this video from TJ DeVries

So I tried the Tree Sitter Playground.
It understands the HTML part because it's the current LSP.
But for the rust part I get ERROR nodes.
So, I'm a bit stuck in this path also.

@alf5
Copy link

alf5 commented Jan 2, 2024

apologies I'm a neovim newbie.
Are the vim files inside https://github.com/rust-sailfish/sailfish/tree/main/syntax/vim useful within NeoVim?
if not, can they be used to help create a neovim plugin?

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