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

Feature Request: Support Neovim/Vim #3290

Open
EkeMinusYou opened this issue Dec 31, 2024 · 6 comments
Open

Feature Request: Support Neovim/Vim #3290

EkeMinusYou opened this issue Dec 31, 2024 · 6 comments

Comments

@EkeMinusYou
Copy link

I love using Neovim and want to edit HCL files in it, but it seems there isn’t support for Neovim/Vim, so I’d like to request one.

@luantranminh
Copy link
Contributor

luantranminh commented Dec 31, 2024

@EkeMinusYou, Thank you for your request! We’re glad to hear about your interest in using Atlas HCL with Neovim. The good news is that Neovim/Vim support is on our roadmap. We’ll make sure to update you as soon as it’s available. Stay tuned!

@giautm
Copy link
Member

giautm commented Dec 31, 2024

@EkeMinusYou we have the lsp-server already. Are you vim-expert? Can you help us testing the lsp-server on Vim? If you free please ping me on our Discord

@EkeMinusYou
Copy link
Author

Thank you for reply!

I’m not a Vim expert, but I’d like to help as much as I can.

Where can I find the lsp-server? I assumed it exists since there’s a VSCode extension, but I wasn’t sure where to locate it.

@a8m
Copy link
Member

a8m commented Dec 31, 2024

You can run the lsp-server using the atlas tool lsp command.

@EkeMinusYou
Copy link
Author

EkeMinusYou commented Jan 2, 2025

Thank you! I'll try it.

@EkeMinusYou
Copy link
Author

EkeMinusYou commented Jan 3, 2025

lsp-server with neovim is worked for me!

Below is the setting using nvim-lspconfig. (I haven't tried it myself, but I think vim can be configured with the same settings.)

-- Setup atlas lsp
local configs = require('lspconfig.configs')
if not configs.atlas then
  configs.atlas = {
    default_config = {
      cmd = { 'atlas', 'tool', 'lsp' },
      filetypes = {
        'atlas-*',
      },
      root_dir = function(fname)
        return lspconfig.util.root_pattern('atlas.hcl')(fname)
      end,
      single_file_support = true,
      settings = {},
    },
  }
end
lspconfig.atlas.setup()

Also, the following autocmd is required to set the language-id.

autocmd BufNewFile,BufRead atlas.hcl set filetype=atlas-config
autocmd BufNewFile,BufRead *.my.hcl set filetype=atlas-schema-mysql
autocmd BufNewFile,BufRead *.pg.hcl set filetype=atlas-schema-postgresql
autocmd BufNewFile,BufRead *.lt.hcl set filetype=atlas-schema-sqlite
autocmd BufNewFile,BufRead *.ch.hcl set filetype=atlas-schema-clickhouse
autocmd BufNewFile,BufRead *.ms.hcl set filetype=atlas-schema-mssql
autocmd BufNewFile,BufRead *.rs.hcl set filetype=atlas-schema-redshift
autocmd BufNewFile,BufRead *.test.hcl set filetype=atlas-test
autocmd BufNewFile,BufRead *.plan.hcl set filetype=atlas-plan

I've created a PR in nvim-lspconfig to make LSP configuration easier.

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