Comments (6)
The way you add options to a language server is by using .configure()
function.
local lsp = require('lsp-zero')
lsp.preset('recommended')
lsp.configure('ansiblels', {
settings = {
ansible = {
ansibleLint = {
arguments = "-x risky-shell-pipe,package-latest,meta-no-info,role-name,yaml[line-length],no-changed-when,fqcn-builtins,name[casing]",
},
},
},
})
lsp.setup()
If you have ansiblels
installed globally in your system, add force_setup = true
in configure
.
lsp.configure('ansiblels', {
force_setup = true,
settings = {
--- your settings....
},
})
from lsp-zero.nvim.
That's strange, that's exactly what I tried earlier, however it then ignores the config of ansiblels
.
use({
"VonHeikemen/lsp-zero.nvim",
requires = {
-- lsp
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" },
-- autocomplete
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
-- snippets
{ "L3MON4D3/LuaSnip" },
{ "rafamadriz/friendly-snippets" },
},
config = function()
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.configure("ansiblels", {
settings = {
ansible = {
ansibleLint = {
arguments = "-x risky-shell-pipe,package-latest,meta-no-info,role-name,yaml[line-length],no-changed-when,fqcn-builtins,name[casing]",
},
},
},
})
lsp.setup()
end,
})
I have installed ansiblels
via mason
and ansible-lint
globally in my system. I have tried with and without force_setup = true
.
from lsp-zero.nvim.
Does the command :LspInfo
shows the language server is attached to the buffer?
Edit:
You can use the id
of the language server to inspect the settings. Use this command.
:lua = vim.lsp.get_client_by_id(<lsp-server-id>).config.settings
from lsp-zero.nvim.
With lsp-zero
config:
config = function()
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.configure("ansiblels", {
settings = {
ansible = {
ansibleLint = {
arguments = "-x risky-shell-pipe,package-latest,meta-no-info,role-name,yaml[line-length],no-changed-when,fqcn-builtins,name[casing]",
},
},
},
})
lsp.setup()
end,
:LspInfo
Use [q] or [Esc] to quit the window
Language client log: /home/dvb/.cache/nvim/lsp.log
Detected filetype: yaml.ansible
2 client(s) attached to this buffer:
Client: ansiblels (id: 1, pid: 40857, bufnr: [1, 3])
filetypes: yaml.ansible
autostart: true
root directory: /home/dvb/git/infrastructure/ansible
cmd: ansible-language-server --stdio
Client: null-ls (id: 2, pid: 5001, bufnr: [1, 3])
filetypes: lua, typescript, javascriptreact, typescriptreact, javascript, vue
autostart: false
root directory: /home/dvb/git/infrastructure
cmd: nvim
Configured servers list: sumneko_lua, dockerls, eslint, clangd, rust_analyzer, cmake, jsonls, ansiblels, pyright, html, marksman, gopls, sqlls, tsserver, bashls, asm_lsp
:lua = vim.lsp.get_client_by_id(1).config.settings
{
ansible = {
ansible = {
path = "ansible"
},
ansibleLint = {
enabled = true,
path = "ansible-lint"
},
executionEnvironment = {
enabled = false
},
python = {
interpreterPath = "python"
}
}
}
With lspconfig
config:
config = function()
require("lspconfig").ansiblels.setup({
settings = {
ansible = {
ansibleLint = {
arguments = "-x risky-shell-pipe,package-latest,meta-no-info,role-name,yaml[line-length],no-changed-when,fqcn-builtins,name[casing]",
},
},
},
})
end,
:LspInfo
Use [q] or [Esc] to quit the window
Language client log: /home/dvb/.cache/nvim/lsp.log
Detected filetype: yaml.ansible
2 client(s) attached to this buffer:
Client: ansiblels (id: 1, pid: 42737, bufnr: [1])
filetypes: yaml.ansible
autostart: true
root directory: /home/dvb/git/infrastructure/ansible
cmd: ansible-language-server --stdio
Client: null-ls (id: 2, pid: 5001, bufnr: [1])
filetypes: lua, vue, javascript, typescriptreact, javascriptreact, typescript
autostart: false
root directory: /home/dvb/git/infrastructure
cmd: nvim
Configured servers list: sumneko_lua, ansiblels, cmake, html, sqlls, pyright, gopls, eslint, marksman, asm_lsp, bashls, clangd, tsserver, dockerls, jsonls, rust_analyzer
:lua = vim.lsp.get_client_by_id(1).config.settings
{
ansible = {
ansible = {
path = "ansible"
},
ansibleLint = {
arguments = "-x risky-shell-pipe,package-latest,meta-no-info,role-name,yaml[line-length],no-changed-when,fqcn-builtins,name[casing]",
enabled = true,
path = "ansible-lint"
},
executionEnvironment = {
enabled = false
},
python = {
interpreterPath = "python"
}
}
}
from lsp-zero.nvim.
I tested in a docker container with a minimal config, everything seems fine.
There is something else going on in your config. I'm actually surprised lspconfig
works on its own without calling mason.nvim
, it should raise an error.
Anyway, if lspconfig
works, you should be able to use it like this.
local lsp = require('lsp-zero')
lsp.preset('recommended')
local ansible_opts = lsp.build_options('ansiblels', {
settings = {
ansible = {
ansibleLint = {
arguments = "-x risky-shell-pipe,package-latest,meta-no-info,role-name,yaml[line-length],no-changed-when,fqcn-builtins,name[casing]",
},
},
},
})
require('lspconfig').ansiblels.setup(ansible_opts)
lsp.setup()
from lsp-zero.nvim.
Thank you so much! This finally works. ❤️
from lsp-zero.nvim.
Related Issues (20)
- Add a version of `luasnip_supertab` that doesn't trigger snippets if the completion menu isn't visible HOT 6
- [ERROR] on startup HOT 2
- friendly-snippets snippets doesn't show up in list HOT 1
- lsp-zero + null-ls formatting issues HOT 2
- Oddly spaced out when using lsp HOT 4
- Avoid changing root_dir when jumping to files outside project HOT 5
- Lazy installation snippet warning HOT 2
- Completion for some languages not working. HOT 4
- highlighting of variables problem HOT 2
- LSP Disabled inside comments HOT 2
- Failed to update VonHeikemen/lsp-zero.nvim/v2.x - Packer HOT 2
- cmp not active HOT 2
- Non-neovim lua projects HOT 2
- No completions without lsp.extend_cmp() HOT 2
- some snippets are gone HOT 2
- How to overwrite <C-e>? HOT 7
- Diagnostic in status line? HOT 3
- Add delay? HOT 2
- Strange "Error executing vim.schedule lua callback' issue, resolved when lsp-zero is uninstalled HOT 2
- Cannot disable tab completion. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp-zero.nvim.