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

Not clear where to put configuration #16

Open
marco-zan opened this issue May 11, 2024 · 7 comments
Open

Not clear where to put configuration #16

marco-zan opened this issue May 11, 2024 · 7 comments

Comments

@marco-zan
Copy link

I would really like to use this language server, but i do not have a clue on where to put the configuration json string.

I am using neovim and installed the lsp using mason, but it is clearly not attaching to buffers.

If more informations are needed just ask me

@johndalloxx
Copy link

I have exactly the same problem, bump!

@uros-5
Copy link
Owner

uros-5 commented May 11, 2024

Check this #6

@johndalloxx
Copy link

johndalloxx commented May 11, 2024

Unsure of what I'm doing wrong, but everywhere where I'm using the {} syntax I get "Undefined variable" warning


{% import 'components/test.html' as tests %} <-- Warning here
            
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>HTML5 Boilerplate</title>
    <link href="../static/output.css" rel="stylesheet">
    <script src="../static/htmx.min.js"></script>
</head>

<body>
    <h1 class="bg-red-50 text-zinc-50">Page Title</h1>
    <h2>Another juan</h2>
    <div class="bg-red-500 text-zinc-50">
        Hello from a box
    </div>
    {{tests.test('test thingy')}} <-- Warning here
    {{request}} <-- Warning here
    <div class="bg-blue-500 text-[50px]">
        {{id}} <-- Warning here
    </div>
</body>

</html>

Although I get snippets help everywhere.

I copied the setup from that other post, but changed lang to python. It doesn't seem to parse the variables from other files.

Am I missing some treesitter thing or something?

    extension = {
        jinja = 'jinja',
        jinja2 = 'jinja',
        j2 = 'jinja',
    },
}

-- uncomment this part if language server is not working
vim.lsp.set_log_level("debug")

local configs = require('lspconfig.configs')

-- try to remove this if statement at the moment and leave only that inner block
-- if it succeeds then add it again

-- if not configs.jinja_lsp then
configs.jinja_lsp = {
    default_config = {
        name = "jinja-lsp",
        cmd = { "/home/john/.cargo/bin/jinja-lsp" },
        filetypes = { "html", "jinja", "rs", "css" },
        root_dir = function(fname)
            return "."
            -- return require("lspconfig").util.find_git_ancestor(fname)
        end,
        init_options = {
            templates = './templates',
            backend = { './src' },
            lang = "python"
        }
    }
}
-- end

require("lspconfig").jinja_lsp.setup {}

lsp.setup()
  src
    __pycache__
     main.py
  static
    󰌞 htmx.min.js
     output.css
  templates
    components
       test.html
     index.html
   input.css
  󰈙 requirements.txt
  󱏿 tailwind.config.js

@marco-zan
Copy link
Author

marco-zan commented May 12, 2024

Check this #6

I in fact checked that and (using my modified version of kickstart) the lsp is started correctly. (I can maybe write a PR to write about it in the readme for future people to see?)

The next problem is that, even if started correctly, when first starting the server it gives me the error: RPC[Error] code_name = InvalidParams, message = "invalid type: string \"utf-8\", expected a sequence"

Edit: I should also mention that i am trying to use it with python. Maybe it's better to use the 'python' branch?

@uros-5
Copy link
Owner

uros-5 commented May 13, 2024

Activate this LSP for Python files, by modifying filetypes.

filetypes = { 'jinja', 'python' },

Can you try to run it with this example?

git clone https://github.com/uros-5/jinja-lsp.git --depth 1
cd jinja-lsp/example
git init .
nvim .

Enable debugging.

@skimask9
Copy link

Activate this LSP for Python files, by modifying filetypes.

filetypes = { 'jinja', 'python' },

Can you try to run it with this example?

git clone https://github.com/uros-5/jinja-lsp.git --depth 1
cd jinja-lsp/example
git init .
nvim .

Enable debugging.

It works, I think the key is initing Git

@marco-zan
Copy link
Author

Activate this LSP for Python files, by modifying filetypes.

filetypes = { 'jinja', 'python' },

Can you try to run it with this example?

git clone https://github.com/uros-5/jinja-lsp.git --depth 1
cd jinja-lsp/example
git init .
nvim .

Enable debugging.

Still the same error. Cannot figure out why.

image

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

4 participants