castwide / solargraph

A Ruby language server.
https://solargraph.org
MIT License
1.87k stars 154 forks source link

No Rubocop linting with Solargraph 0.50 when using Kate Editor #703

Open rriemann opened 6 months ago

rriemann commented 6 months ago

Dear all,

I want to use solargraph inside of Kate Editor to receive rubocop linting.

I get method definitions and method completition popups in kate. However, linting is not working.

My Kate settings:

image

Screenshot of an editing session:

image

My solargraph config:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
formatter:
  rubocop:
    cops: safe
    except: []
    only: []
    extra_args: []
require_paths: []
plugins: []
max_files: 5000

Rubocop config .rubocop.yml:

File content

~~~yml --- AllCops: TargetRubyVersion: 3.1 Include: - lib/**/*.rb # - spec/**/*.rb NewCops: enable SuggestExtensions: false Layout/EndAlignment: Severity: error Lint/UnreachableCode: Severity: error Lint/UselessAccessModifier: Enabled: false Metrics/AbcSize: Max: 20 Metrics/BlockLength: Exclude: - spec/**/*.rb Metrics/ClassLength: Max: 300 Exclude: - !ruby/regexp /spec\/.*.rb$/ Metrics/CyclomaticComplexity: Max: 8 Layout/LineLength: Exclude: - Rakefile - Gemfile - jekyll-maps.gemspec Max: 90 Severity: warning Metrics/MethodLength: Max: 20 CountComments: false Severity: error Metrics/ModuleLength: Max: 240 Metrics/ParameterLists: Max: 4 Metrics/PerceivedComplexity: Max: 8 Style/Alias: Enabled: false Style/AndOr: Severity: error Style/Attr: Enabled: false Style/ClassAndModuleChildren: Enabled: false Style/Documentation: Enabled: false Style/DoubleNegation: Enabled: false Layout/EmptyLinesAroundAccessModifier: Enabled: false Layout/EmptyLinesAroundModuleBody: Enabled: false Layout/ExtraSpacing: AllowForAlignment: true Naming/FileName: Enabled: false Layout/FirstParameterIndentation: EnforcedStyle: consistent Style/GuardClause: Enabled: false Style/HashSyntax: EnforcedStyle: hash_rockets Severity: error Style/IfUnlessModifier: Enabled: false Layout/IndentationWidth: Severity: error Style/ModuleFunction: Enabled: false Layout/MultilineMethodCallIndentation: EnforcedStyle: indented Layout/MultilineOperationIndentation: EnforcedStyle: indented Style/MultilineTernaryOperator: Severity: error Style/PercentLiteralDelimiters: PreferredDelimiters: "%q": "{}" "%Q": "{}" "%r": "!!" "%s": "()" "%w": "()" "%W": "()" "%x": "()" Style/RedundantReturn: Enabled: false Style/RedundantSelf: Enabled: false Style/RegexpLiteral: EnforcedStyle: percent_r Style/RescueModifier: Enabled: false Style/SignalException: EnforcedStyle: only_raise Style/SingleLineMethods: Enabled: false Layout/SpaceAroundOperators: Enabled: false Style/StringLiterals: EnforcedStyle: double_quotes Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes Style/RedundantCapitalW: Enabled: false Style/SymbolArray: Enabled: false ~~~

I have configured to use ruby-3.1.2 with rvm (.ruby-version file). Kate Version 23.08.2 on opensuse tumbleweed linux 64bit

Any ideas how I can get it working? Once this is working, I can help to document this for a kate section at https://solargraph.org/guides .

castwide commented 6 months ago

Try turning on diagnostics with an initializationOptions or settings object.

"ruby": {
  "initializationOptions": {
    "diagnostics": true
  }
}

or

"ruby": {
  "settings": {
    "diagnostics": true
  }
}
rriemann commented 6 months ago

I added:

      "ruby": {
        "settings": {
          "diagnostics": true
        }
      },

Since then, it seems to work:

image

Note however, that diagnostics was activated in the Kate menu before and this was not enough:

image

I ask in the Kate community what the expected behaviour of this menu is.

castwide commented 6 months ago

Fair point. In the early days of Solargraph, diagnostics support was experimental, so it was disabled by default. Nowadays, diagnostics work well and are configurable through .solargraph.yml, so it make sense to enable it by default now. I'll look into making that change.