diff options
| author | Lorenzo Bellina <59364991+TheRealLorenz@users.noreply.github.com> | 2025-04-13 00:15:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-12 15:15:43 -0700 |
| commit | 81a570f58b2113cc2d538efae743ad38d6ab564f (patch) | |
| tree | 74f9691bbb1b303cd7cfaab7b543f82cb0dc6b46 /lsp/atlas.lua | |
| parent | refactor: replace vim.loop with vim.uv #3703 (diff) | |
| download | nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.gz nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.bz2 nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.lz nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.xz nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.zst nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.zip | |
feat: migrate to vim.lsp.config #3659
Problem:
Nvim 0.11 has vim.lsp.config, which mostly replaces the legacy
nvim-lspconfig "framework".
Solution:
Migrate all configs to `lsp/*` variants. The old configs in
`lua/lspconfig/` are "frozen".
The new configs include these changes:
- `commands` field became raw calls to
`vim.api.nvim_buf_create_user_command` inside `on_attach`.
- `root_dir` became:
- `root_markers` whenever the file list was simple didn't need to mach `*`
- if the logic was complicated, or needed to match something like
'\*.c', it was defined as a vim.lsp.Config `root_dir` callback.
- `on_config_change` became `before_init`. I don't actually know if this
is the correct approach, but looking around the documentation of
`nvim-lspconfig` a saw that it was defined as the function that gets
called as soon as the config have `root_dir`, and so I thought
`before_init` might be the closest alternative.
- `docs.description` became a luadoc `@brief` docstring.
- `single_file_support = false`?
Co-authored-by: Aliou Diallo <aliou@users.noreply.github.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'lsp/atlas.lua')
| -rw-r--r-- | lsp/atlas.lua | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lsp/atlas.lua b/lsp/atlas.lua new file mode 100644 index 00000000..f8747ae9 --- /dev/null +++ b/lsp/atlas.lua @@ -0,0 +1,59 @@ +---@brief +--- +---https://github.com/ariga/atlas +-- +-- Language server for Atlas config and scheme files. +-- +-- You may also need to configure the filetype for *.hcl files: +-- +-- `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` +-- +-- or +-- +-- ```lua +-- vim.filetype.add({ +-- filename = { +-- ['atlas.hcl'] = 'atlas-config', +-- }, +-- pattern = { +-- ['.*/*.my.hcl'] = 'atlas-schema-mysql', +-- ['.*/*.pg.hcl'] = 'atlas-schema-postgresql', +-- ['.*/*.lt.hcl'] = 'atlas-schema-sqlite', +-- ['.*/*.ch.hcl'] = 'atlas-schema-clickhouse', +-- ['.*/*.ms.hcl'] = 'atlas-schema-mssql', +-- ['.*/*.rs.hcl'] = 'atlas-schema-redshift', +-- ['.*/*.test.hcl'] = 'atlas-test', +-- ['.*/*.plan.hcl'] = 'atlas-plan', +-- }, +-- }) +-- ``` +-- +-- Optionally, tell treesitter to treat Atlas filetypes as HCL for better syntax highlighting: +-- +-- ```lua +-- vim.treesitter.language.register('hcl', 'atlas-config') +-- vim.treesitter.language.register('hcl', 'atlas-schema-mysql') +-- vim.treesitter.language.register('hcl', 'atlas-schema-postgresql') +-- vim.treesitter.language.register('hcl', 'atlas-schema-sqlite') +-- vim.treesitter.language.register('hcl', 'atlas-schema-clickhouse') +-- vim.treesitter.language.register('hcl', 'atlas-schema-mssql') +-- vim.treesitter.language.register('hcl', 'atlas-schema-redshift') +-- vim.treesitter.language.register('hcl', 'atlas-test') +-- vim.treesitter.language.register('hcl', 'atlas-plan') +-- ``` +-- +return { + cmd = { 'atlas', 'tool', 'lsp', '--stdio' }, + filetypes = { + 'atlas-*', + }, + root_markers = { 'atlas.hcl' }, +} |
