1

With the current default configuration of the "docker_compose_language_service" LSP, it will not start, nor attach after being started to the current buffer.

When taking a look at the configuration here: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#docker_compose_language_service

I noticed that the file type is, "yaml.docker-compose". However docker-compose files are usually postfixed with either .yaml or .yml so the filetype will never be detected as such.

The way I got around this is running :setfiletype yaml.docker-compose and then the LSP would behave normally. The first solution I thought was to change the filetypes from the setup to .yaml and .yml but I don't think that's the right approach.

In my neovim configuration, I now have this in my options.lua to automatically run this depending on whether the file is named, "docker-compose.yaml".

function docker_fix()
    local filename = vim.fn.expand("%:t")

    if filename == "docker-compose.yaml" then
        vim.bo.filetype = "yaml.docker-compose"
        print("matched!")
    else
        print(filename)
    end
end

vim.cmd[[au BufRead * lua docker_fix()]]

I don't think this normal behavior. Is having the filetype, "yaml.docker-compose" intended or is there something wrong with my working environment? The only other thing I can think of is that the current working directory does have a docker-compose.yaml (and of course it would, I'm working on that exact file!) and it doesn't pick up the current_dir as the root_dir.

If anyone could give me a clue or insight, I'd appreciate it. Thank you!

1
  • I believe your solution is the good one. filetype and file extension are not supposed to be the same. The yaml.docker-compose is a combined filetype that trigger the yaml filetype extensions and the docker-compose filetype extension. Nov 20 at 1:04

1 Answer 1

1

I believe your solution is the good one.

Remark: filetype and file extension are not supposed to be the same.

The yaml.docker-compose is a combined filetype that triggers both the yaml filetype extensions and the docker-compose filetype extension.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.