LaurenceWarne / cfn-lsp-extra

An Experimental Cloudformation language server
MIT License
21 stars 5 forks source link

Neovim - AttributeError: 'DiagnosticPublishingMethod' object has no attribute 'upper #7

Open createchange opened 9 months ago

createchange commented 9 months ago

Hi there,

I followed the example in the README for configuring this with lspconfig, and received the following errors:

AttributeError: 'DiagnosticPublishingMethod' object has no attribute 'upper'\n"

The logs are more verbose than this, and I can provide them if the above doesn't tell the story.

I see upper is used in cfn_lsp_extra/config/user_configuration.py, but need to get back to the task at hand so don't have time to go down a rabbit hole.

Hoping for a fix so that I can make use of your tool. Been on the lookout for something that will provide more than yamlls has been!

LaurenceWarne commented 9 months ago

Hi! Sorry to hear you've been having issues using the package. I think I can possibly see where the error is occurring, would you able to build from master to check a fix I've pushed?:

pipx install git+https://github.com/laurencewarne/cfn-lsp-extra.git@$(git ls-remote git@github.com:laurencewarne/cfn-lsp-extra.git | head -1 | cut -f1) --force

If not, could you provide a stack trace/log and python version?

Thanks!

createchange commented 9 months ago

That works better. I get autocompletion and linting, though snippets seem to function a bit worse than I am seeing in the video on the README. For example, when I follow what is on the video and implement a new VPC, get a new Properties block, but no auto-fill for the CIDR property.

On a side note, in the event it is helpful for anyone else, two more changes are required:

        local line2 = vim.filetype.getlines(bufnr, 2)
        if vim.filetype.matchregex(line1, [[^AWSTemplateFormatVersion]] ) or
           vim.filetype.matchregex(line2, [[^AWSTemplateFormatVersion]] ) or <-------------
           vim.filetype.matchregex(line1, [[AWS::Serverless-2016-10-31]] ) then
          return 'yaml.cloudformation'
vim.treesitter.language.register("yaml", "yaml.cloudformation")
LaurenceWarne commented 9 months ago

That works better. I get autocompletion and linting, though snippets seem to function a bit worse than I am seeing in the video on the README. For example, when I follow what is on the video and implement a new VPC, get a new Properties block, but no auto-fill for the CIDR property.

I think it may be the video is out of date, currently the CIDR required property is marked as Conditional rather than yes which I'm guessing was the case when the video was made (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html#cfn-ec2-vpc-cidrblock) - only required = yes is included in snippets. Does snippet expansion for something like AWS::EC2::VPCGatewayAttachment work (here VpcId has required: yes)?

On a side note, in the event it is helpful for anyone else, two more changes are required:

That looks super helpful, would you be willing to put together a PR to update this? :slightly_smiling_face: (I'm somewhat of a neovim noob!)

LaurenceWarne commented 9 months ago

FYI I cut a new release for the configuration error, so that should be generally available now :slightly_smiling_face:

createchange commented 9 months ago

Hi again, that makes perfect sense. I’ll check it out and report back! I’m also a bit of a neovim noob, but I can certainly provide an MR and others can improve it if they see the need to.