From 3cae3d93bf11da129d557a3cad946539d3fa5dff Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 18 Oct 2024 12:53:28 +0100 Subject: [PATCH] feat(language/ruby): switch to ruby-ts-mode --- modules/completion/siren-copilot.el | 4 + modules/languages/siren-ruby.el | 99 ++++++++++++++++----- themes/siren-doom-themes-overrides-theme.el | 1 + 3 files changed, 82 insertions(+), 22 deletions(-) diff --git a/modules/completion/siren-copilot.el b/modules/completion/siren-copilot.el index 5991d9e..e5a48ed 100644 --- a/modules/completion/siren-copilot.el +++ b/modules/completion/siren-copilot.el @@ -85,6 +85,10 @@ :replace "\\1") (:match "\\`\s*do\\( |.+|\\)?\\'" :before "\n" :after "\nend"))) + (ruby-ts-mode . ((:match "\\([^\s]+\s+\\)do\\(?: |.+|\\)?\\'" + :replace "\\1") + (:match "\\`\s*do\\( |.+|\\)?\\'" + :before "\n" :after "\nend"))) (t . (;; Strip opening "{" from end of completion. (:match "\\([^\s]+\s*\\)\{\\'" :replace "\\1") ;; Inject closing "}" on newline if completion is only "{" or " {". diff --git a/modules/languages/siren-ruby.el b/modules/languages/siren-ruby.el index 2e360e8..8ea496e 100644 --- a/modules/languages/siren-ruby.el +++ b/modules/languages/siren-ruby.el @@ -97,28 +97,28 @@ (if (fboundp 'ruby-ts-mode) (use-package ruby-ts-mode :straight (:type built-in) - ;; :interpreter "ruby" - ;; :mode - ;; "Appraisals\\'" - ;; "Berksfile\\'" - ;; "Brewfile\\'" - ;; "Capfile\\'" - ;; "Gemfile\\'" - ;; "Guardfile\\'" - ;; "Podfile\\'" - ;; "Puppetfile\\'" - ;; "Rakefile\\'" - ;; "Thorfile\\'" - ;; "Vagrantfile\\'" - ;; "\\.cap\\'" - ;; "\\.gemspec\\'" - ;; "\\.jbuilder\\'" - ;; "\\.podspec\\'" - ;; "\\.rabl\\'" - ;; "\\.rake\\'" - ;; "\\.ru\\'" - ;; "\\.thor\\'" - ;; "\\.rb\\'" + :interpreter "ruby" + :mode + "Appraisals\\'" + "Berksfile\\'" + "Brewfile\\'" + "Capfile\\'" + "Gemfile\\'" + "Guardfile\\'" + "Podfile\\'" + "Puppetfile\\'" + "Rakefile\\'" + "Thorfile\\'" + "Vagrantfile\\'" + "\\.cap\\'" + "\\.gemspec\\'" + "\\.jbuilder\\'" + "\\.podspec\\'" + "\\.rabl\\'" + "\\.rake\\'" + "\\.ru\\'" + "\\.thor\\'" + "\\.rb\\'" :general (:keymaps 'ruby-ts-mode-map @@ -242,6 +242,61 @@ and will break things." (add-to-list 'safe-local-variable-values '(lsp-solargraph-use-bundler . t))) +;; (use-package lsp-ruby-lsp +;; :straight lsp-mode + +;; :hook +;; (ruby-mode . siren-lsp-ruby-lsp-mode-setup) + +;; :custom +;; (lsp-solargraph-multi-root nil) +;; (lsp-solargraph-log-level "warn") + +;; :preface +;; (defun siren-lsp-ruby-lsp-format-on-save-p () +;; "Determine if format on save (FoS) should be enabled in the current buffer. + +;; Returns t if FoS should be enabled, nil otherwise. + +;; Currently only disables FoS in 'db/schema.rb' files, as Rails' generated +;; output typically does not conform to any common Ruby formatting standards." +;; (let ((db-schema-file (concat (file-name-as-directory "db") "schema.rb"))) +;; (or (not buffer-file-name) +;; (not (string-suffix-p db-schema-file buffer-file-name))))) + +;; (defun siren-lsp-ruby-lsp-mode-setup () +;; (setq-local siren-lsp-manual-format-buffer-func +;; 'siren-lsp-ruby-lsp-manual-format-buffer) + +;; ;; Disable ruby clients which have higher priority than the ruby-lsp-ls +;; ;; client. +;; (setq-local lsp-disabled-clients '(vue-semantic-server ruby-ls rubocop-ls)) + +;; ;; Disable semantic tokens as it typically causes an annoying delay with the +;; ;; syntax highlighting as you type. Essentially all new text is a very faded +;; ;; out grey color for the first 1-2 seconds as you type. +;; (setq-local lsp-semantic-tokens-enable nil) + +;; ;; Enable format on save if the predicate returns true. +;; (when (siren-lsp-ruby-lsp-format-on-save-p) +;; (lsp-format-buffer-on-save-mode t)) + +;; (lsp-deferred)) + +;; (defun siren-lsp-ruby-lsp-manual-format-buffer () +;; (stree-format-buffer) +;; (lsp-format-buffer)) + +;; ;; :config +;; ;; (lsp-register-client +;; ;; (make-lsp-client +;; ;; :new-connection (lsp-stdio-connection #'lsp-rubocop--build-command) +;; ;; :activation-fn (lsp-activate-on "ruby") +;; ;; :priority -1 +;; ;; :server-id 'rubocop-lsp +;; ;; :add-on? t)) +;; ) + (use-package dap-ruby :straight dap-mode :after (ruby-mode dap-mode)) diff --git a/themes/siren-doom-themes-overrides-theme.el b/themes/siren-doom-themes-overrides-theme.el index 4747c69..078ac7e 100644 --- a/themes/siren-doom-themes-overrides-theme.el +++ b/themes/siren-doom-themes-overrides-theme.el @@ -24,6 +24,7 @@ (&dark :foreground (doom-darken vertical-bar (if window-system 0.4 0)))) '(font-lock-comment-face :foreground (doom-lighten comments 0.15)) + '(font-lock-operator-face :inherit 'font-lock-keyword-face) ;; built-in completion faces, based on doom-themes' defaults for orderless '(completions-common-part :weight 'bold