Class: Mui::Lsp::ConfigDsl

Inherits:
Object
  • Object
show all
Defined in:
lib/mui/lsp/plugin.rb

Overview

DSL class for configuring LSP in .muirc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(existing_configs = []) ⇒ ConfigDsl

Returns a new instance of ConfigDsl.



512
513
514
515
516
# File 'lib/mui/lsp/plugin.rb', line 512

def initialize(existing_configs = [])
  @server_configs = []
  # Import configs from LspConfigStub if any were defined before gem load
  import_stub_configs(existing_configs)
end

Instance Attribute Details

#server_configsObject (readonly)

Returns the value of attribute server_configs.



510
511
512
# File 'lib/mui/lsp/plugin.rb', line 510

def server_configs
  @server_configs
end

Instance Method Details

#server(name:, command:, language_ids:, file_patterns:, auto_start: true, sync_on_change: true) ⇒ Object



535
536
537
538
539
540
541
542
543
544
# File 'lib/mui/lsp/plugin.rb', line 535

def server(name:, command:, language_ids:, file_patterns:, auto_start: true, sync_on_change: true)
  @server_configs << ServerConfig.custom(
    name: name,
    command: command,
    language_ids: language_ids,
    file_patterns: file_patterns,
    auto_start: auto_start,
    sync_on_change: sync_on_change
  )
end

#use(name, sync_on_change: nil) ⇒ Object



518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/mui/lsp/plugin.rb', line 518

def use(name, sync_on_change: nil)
  config = case name.to_sym
           when :solargraph
             ServerConfig.solargraph(auto_start: true)
           when :ruby_lsp
             # ruby_lsp defaults to sync_on_change: false
             ServerConfig.ruby_lsp(auto_start: true, sync_on_change: sync_on_change.nil? ? false : sync_on_change)
           when :rubocop
             ServerConfig.rubocop_lsp(auto_start: true)
           when :kanayago
             ServerConfig.kanayago(auto_start: true)
           else
             raise ArgumentError, "Unknown server: #{name}. Use :solargraph, :ruby_lsp, :rubocop, or :kanayago"
           end
  @server_configs << config
end