Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #14509

Merged
merged 53 commits into from
Apr 4, 2021
Merged

Refactor #14509

merged 53 commits into from
Apr 4, 2021

Conversation

lebensterben
Copy link
Collaborator

@lebensterben lebensterben commented Mar 18, 2021

  • Refactored function
    • layers/+frameworks/react/func.el
    • layers/+lang/c-c++/layers.el
    • layers/+lang/elm/funcs.el
    • layers/+lang/julia/packages.el
    • layers/+lang/latex/funcs.el
    • layers/+lang/lua/funcs.el
    • layers/+lang/nim/funcs.el
    • layers/+lang/perl5/funcs.el
    • layers/+lang/purescript/funcs.el
    • layers/+spacemacs/spacemacs-editing/local/spacemacs-whitespace-cleanup/spacemacs-whitespace-cleanup.el
    • layers/+spacemacs/spacemacs-editing/packages.el
    • layers/+tools/cmake/funcs.el
    • layers/+tools/eaf/packages.el
    • layers/+tools/terraform/funcs.el
  • Moved backend determination to config.el
    • layers/+lang/c-c++/config.el
    • layers/+lang/clojure/config.el
    • layers/+lang/crystal/config.el
    • layers/+lang/elixir/config.el
    • layers/+lang/elm/config.el
    • layers/+lang/erlang/config.el
    • layers/+lang/ess/config.el
    • layers/+lang/fsharp/config.el
    • layers/+lang/go/config.el
    • layers/+lang/groovy/config.el
    • layers/+lang/haskell/config.el
    • layers/+lang/java/config.el
    • layers/+lang/javascript/config.el
    • layers/+lang/json/config.el
    • layers/+lang/julia/config.el
    • layers/+lang/kotlin/config.el
    • layers/+lang/latex/config.el
    • layers/+lang/lua/config.el
    • layers/+lang/nim/config.el
    • layers/+lang/purescript/config.el
    • layers/+lang/python/config.el
    • layers/+lang/ruby/config.el
    • layers/+lang/rust/config.el
    • layers/+lang/shell-scripts/config.el
    • layers/+lang/sql/config.el
    • layers/+lang/typescript/config.el
    • layers/+lang/vimscript/config.el
    • layers/+tools/cmake/config.el
    • layers/+tools/terraform/config.el
  • Moved function from packages.el to func.el
    • layers/+frameworks/react/packages.el
    • layers/+lang/fsharp/packages.el
  • Replaced (set (make-local-variable 'foo) bar) with (setq-local foo bar)
    • core/core-dotspacemacs.el
    • core/libs/ido-vertical-mode.el
    • layers/+chat/rcirc/packages.el
    • layers/+intl/chinese/packages.el
    • layers/+lang/c-c++/funcs.el
    • layers/+lang/javascript/funcs.el
    • layers/+lang/typescript/funcs.el
    • layers/+vim/vinegar/funcs.el
  • Replaced (when (not foo) bar) with (unless foo bar)
    • layers/+chat/rcirc/funcs.el
    • layers/+distributions/spacemacs-bootstrap/funcs.el
    • layers/+distributions/spacemacs-bootstrap/packages.el
    • layers/+frameworks/react/funcs.el
    • layers/+fun/xkcd/packages.el
    • layers/+intl/keyboard-layout/funcs.el
    • layers/+lang/c-c++/config.el
    • layers/+lang/clojure/packages.el
    • layers/+lang/javascript/funcs.el
    • layers/+lang/julia/funcs.el
    • layers/+lang/typescript/funcs.el
    • layers/+readers/dash/funcs.el
    • layers/+spacemacs/spacemacs-defaults/funcs.el
    • layers/+themes/colors/funcs.el
    • layers/+tools/eaf/funcs.el
  • Replaced unnecessary backquote construct with simple quotation
    • layers/+distributions/spacemacs-bootstrap/packages.el
    • layers/+frameworks/react/funcs.el
    • layers/+lang/c-c++/funcs.el
    • layers/+lang/c-c++/layers.el
    • layers/+lang/c-c++/packages.el
    • layers/+lang/crystal/funcs.el
    • layers/+lang/csharp/funcs.el
    • layers/+lang/dart/funcs.el
    • layers/+lang/elixir/funcs.el
    • layers/+lang/elm/funcs.el
    • layers/+lang/go/funcs.el
    • layers/+lang/groovy/funcs.el
    • layers/+lang/haskell/funcs.el
    • layers/+lang/java/funcs.el
    • layers/+lang/javascript/funcs.el
    • layers/+lang/latex/funcs.el
    • layers/+lang/nim/funcs.el
    • layers/+lang/perl5/funcs.el
    • layers/+lang/python/funcs.el
    • layers/+lang/python/packages.el
    • layers/+lang/ruby/funcs.el
    • layers/+lang/rust/funcs.el
    • layers/+lang/typescript/funcs.el
    • layers/+spacemacs/spacemacs-editing/local/spacemacs-whitespace-cleanup/spacemacs-whitespace-cleanup.el
  • Replaced pcase form with only one-arm with when or unless form
    • layers/+frameworks/react/funcs.el
    • layers/+frameworks/vue/funcs.el
    • layers/+lang/c-c++/funcs.el
    • layers/+lang/clojure/funcs.el
    • layers/+lang/crystal/funcs.el
    • layers/+lang/csharp/funcs.el
    • layers/+lang/elixir/funcs.el
    • layers/+lang/elixir/packages.el
    • layers/+lang/erlang/funcs.el
    • layers/+lang/fsharp/funcs.el
    • layers/+lang/go/funcs.el
    • layers/+lang/go/packages.el
    • layers/+lang/groovy/funcs.el
    • layers/+lang/haskell/funcs.el
    • layers/+lang/java/funcs.el
    • layers/+lang/java/packages.el
    • layers/+lang/javascript/funcs.el
    • layers/+lang/javascript/packages.el
    • layers/+lang/json/funcs.el
    • layers/+lang/julia/funcs.el
    • layers/+lang/kotlin/funcs.el
    • layers/+lang/latex/funcs.el
    • layers/+lang/lua/funcs.el
    • layers/+lang/perl5/funcs.el
    • layers/+lang/perl5/packages.el
    • layers/+lang/php/funcs.el
    • layers/+lang/php/packages.el
    • layers/+lang/purescript/funcs.el
    • layers/+lang/python/funcs.el
    • layers/+lang/python/packages.el
    • layers/+lang/ruby/funcs.el
    • layers/+lang/ruby/packages.el
    • layers/+lang/rust/funcs.el
    • layers/+lang/rust/packages.el
    • layers/+lang/scala/packages.el
    • layers/+lang/shell-scripts/funcs.el
    • layers/+lang/sql/funcs.el
    • layers/+lang/typescript/funcs.el
    • layers/+lang/vimscript/funcs.el
    • layers/+tools/cmake/funcs.el
    • layers/+tools/dap/README.org
    • layers/+tools/docker/funcs.el
    • layers/+tools/terraform/funcs.el
  • Removed unnecessary progn
    • layers/+lang/c-c++/funcs.el
    • layers/+lang/elixir/funcs.el
    • layers/+lang/nim/funcs.el
  • Replaccd (cond ((eq foo) bar)) form with (pcase (foo bar))
    • layers/+lang/javascript/funcs.el
    • layers/+lang/lua/funcs.el
    • layers/+lang/python/funcs.el
    • layers/+lang/typescript/funcs.el
    • layers/+lang/typescript/packages.el
  • Replaced (if foo bar nil) with (when foo bar)
    • layers/+lang/typescript/packages.el

@lebensterben lebensterben marked this pull request as ready for review March 18, 2021 05:23
@smile13241324
Copy link
Collaborator

Whao this is a lot of changes. You did run some tests against these haven't you?

About Moved backend determination to config.el I personally like this idea however I am not sure why we haven't done this in the first place, lets ask the others first maybe there was a reason for not doing this in the original design.

For the rest I will make individual reviews and sent my feedback one by one.

@lebensterben
Copy link
Collaborator Author

About Moved backend determination to config.el I personally like this idea however I am not sure why we haven't done this in the first place, lets ask the others first maybe there was a reason for not doing this in the original design.

This is just a coincidence I believe.
The current behaviour of determining lsp backend at runtime, more specifically at every call of spacemacs/XX-backend, is introduced in this ac30247

Then when people adding LSP support to other layers, they just followed the existing pattern.
One thing to notice that we haven't played with default value of layer variables much, and we often determine/infer things in packages.el or funcs.el instead, including which bakcend/formatter to use and etc.

After we finished the migration to defcustom based config variables, we can review what else can be done like in this PR.

@lebensterben
Copy link
Collaborator Author

@smile13241324
Any feedback?

@duianto
Copy link
Collaborator

duianto commented Mar 31, 2021

smile became busy at work.

I took a look at the commits and this is great. 👍

The ci/circlci: Validate PR test failed with the message: Please rebase your PR

If you rebase, then I can merge this.

If there are any possible improvements to be made,
then they can be applied when smile gets more time for Spacemacs.

@lebensterben
Copy link
Collaborator Author

I will rebase a while later

- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Replaced unnecessary backquote construct with simple quotation
- Refactored functions
  - Several functions are inlined and removed from global namespace
- Moved function from `packages.el` to `func.el`
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Replaced unnecessary backquote construct with simple quotation
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Moved backend determination to `config.el`
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Replaced unnecessary backquote construct with simple quotation
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
- Removed unnecessary `progn`
- Moved backend determination to `config.el`
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Moved backend determination to `config.el`
- Replaced unnecessary backquote construct with simple quotation
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced unnecessary backquote construct with simple quotation
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced unnecessary backquote construct with simple quotation
- Moved backend determination to `config.el`
- Replaced unnecessary backquote construct with simple quotation
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Removed unnecessary `progn`
- Moved backend determination to `config.el`
- Refactored function
- Replaced unnecessary backquote construct with simple quotation
- Moved backend determination to `config.el`
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Moved backend determination to `config.el`
- Moved backend determination to `config.el`
- Replaced unnecessary backquote construct with simple quotation
- Moved function from `packages.el` to `func.el`
- Moved backend determination to `config.el`
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced unnecessary backquote construct with simple quotation
- Moved backend determination to `config.el`
- Replaced unnecessary backquote construct with simple quotation
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Moved backend determination to `config.el`
- Refactored function
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced `(set (make-local-variable 'foo) bar)` with `(setq-local foo bar)`
@lebensterben
Copy link
Collaborator Author

@duianto

I just rebased. Let me know if you want me to combine them into one commit.

@duianto duianto merged commit 3b7650e into syl20bnr:develop Apr 4, 2021
@duianto
Copy link
Collaborator

duianto commented Apr 4, 2021

Thank you for contributing to Spacemacs.

sdwolfz pointed out that, since each commit describes it's changes, let's keep them separate.

@duianto
Copy link
Collaborator

duianto commented Apr 4, 2021

The emacspace bot wants to revert the ido-vertical-mode.el changes:
https://github.com/syl20bnr/spacemacs/pull/14573/files#diff-606d1dcd79a6fefd96a1f3b99eb4074f2f3ceb6a78f9d86c1720282926a4d46e

The bot might be checking for differences against the upstream file:
https://github.com/creichert/ido-vertical-mode.el/blob/b1659e967da0687abceca733b389ace24004fa66/ido-vertical-mode.el#L161-L162

   ""                                                                        ; right bracket around the sole remaining completion
   ))

https://github.com/creichert/ido-vertical-mode.el/blob/b1659e967da0687abceca733b389ace24004fa66/ido-vertical-mode.el#L321

  (set (make-local-variable 'truncate-lines) nil))

Those changes should probably be suggested upstream, then the bot will open a PR here when it detects that they have changed upstream.

@hrkrshnn
Copy link

hrkrshnn commented Apr 4, 2021

@lebensterben after this PR, I get an error saying that the variable c-c++-backend is null.

I think the problem is https://github.com/syl20bnr/spacemacs/blob/develop/layers/+lang/c-c++/layers.el#L24

A quick fix was to add (defvar c-c++-backend 'lsp-clangd) right above that line.

duianto added a commit that referenced this pull request Apr 4, 2021
This reverts commit dae0231.

c-c++-backend is void on startup:
#14509 (comment)
@duianto
Copy link
Collaborator

duianto commented Apr 4, 2021

I reverted the refactoring of the c-c++ layer.

I'll check the rest of the layers if they work as expected.
Sorry for not testing this more thoroughly.

@duianto
Copy link
Collaborator

duianto commented Apr 4, 2021

None of the other refactored layers break Spacemacs on startup.

@lebensterben
Copy link
Collaborator Author

I will take a look of c-c++ layer

@duianto
Copy link
Collaborator

duianto commented Apr 4, 2021

I think I found the cause.
A single quote was missing in:
Before:

(when (boundp c-c++-backend)

After:

(when (boundp 'c-c++-backend)

in c-c++/layers.el

There is no void variable message on startup with the single quote added.

@lebensterben
Copy link
Collaborator Author

lebensterben commented Apr 4, 2021

I will review each of them once again.

Review progress
  • haskell
  • c-c++
  • rcirc
  • spacemacs-bootstrap
  • react
  • vue
  • xkcd
  • chinese
  • keyboard-layout
  • clojure
  • crystal
  • csharp
  • dart
  • elixir
  • elm
  • erlang
  • ess
  • fsharp
  • go
  • python
  • groovy
  • spacemacs-editing
  • javascript
  • typescript
  • java
  • json
  • julia
  • kotlin
  • latex
  • lua
  • nim
  • perl5
  • php
  • purescript
  • ruby
  • rust
  • scala
  • shell-scripts
  • sql
  • vimscript
  • spacemacs-defaults
  • dash
  • colors
  • cmake
  • dap
  • docker
  • eaf
  • terraform
  • vinegar

All done.

lebensterben added a commit to lebensterben/spacemacs that referenced this pull request Apr 4, 2021
@lebensterben lebensterben deleted the backend-check branch April 4, 2021 17:12
duianto pushed a commit that referenced this pull request Apr 4, 2021
This reverts commit e62d55b.

This fixs #14509 (comment)
@duianto
Copy link
Collaborator

duianto commented Apr 4, 2021

The python and tide layers seems to have issues:
https://gitter.im/syl20bnr/spacemacs?at=6069fb9992a3431fd67544f9

I do think you two should be careful with your current changes across all layers on dev branch. This is madness. My tide layer and and python just break. Python layer won't work with lsp. Because your new change in spacemacs//python-setup-lsp:

(pcase python-lsp-server
                   ('mspyls 'lsp-python-ms)
                   ('pyright 'lsp-pyright))

will always return nil because of the extra quote

I get the intention but as user I can't check all other layers.

Could you prioritize the python and tide layers next.

Update:
Thanks for the python fix.
fixup! python: refactor #14594

As mentioned on gitter.
https://gitter.im/syl20bnr/spacemacs?at=606a0c69db595f5599d59023
tide wasn't referring to the layer, but it's probably referring to react, javascript or typescript.

We might have to wait for more info from @thanhvg or someone else that is experiencing a tide issue.

@thanhvg
Copy link
Contributor

thanhvg commented Apr 4, 2021

Hi, it works again I don't see any problem anymore. Just a bad timing to check out dev branch. Thanks.

@sunlin7
Copy link
Contributor

sunlin7 commented Apr 5, 2021

The current behaviour of determining lsp backend at runtime, more specifically at every call of spacemacs/XX-backend, is introduced in this ac30247

For some one who enable/disable lsp feature from config layer and evaluate .spacemacs file again and again, the spacemacs/XX-backend will keep behavior as expected, while current changes do NOT follow the config layer changes.
Please consider the compatible for the situation that user change the config layer and "SPC e f R" to apply new settings without restarting.
@lebensterben @smile13241324

@lebensterben
Copy link
Collaborator Author

@sunlin7
This is the expected behavior of this PR.
It's not a bug, but a feature.

You are still able to change to other backend by changing the value of the corresponding layer variable, in dotspacemacs or in IELM.

I don't understand how this causes any compatibility issue.

@sunlin7
Copy link
Contributor

sunlin7 commented Apr 6, 2021

Hi @lebensterben ,

The reproducing steps are:

  1. Please Config dotspacemacs-configuration-layers to '(c-c++), restart spacemacs, now variable c-c++-backend is nil.

  2. Open .spacemacs by press SPC f e d, and add lsp to dotspacemacs-configuration-layers, then press SPC f e R to apply the new config layer value, the c-c++-backend is nil (restarting Spacemacs can get the new vlaue); while former spacemacs/XX-backend can work with new configuration vlaue without restarting.

@lebensterben
Copy link
Collaborator Author

@sunlin7
I don't get it.

So you'd prefer to compute the value for a missing layer variable on each initialization of a layer, than just compute it once with the only additional requirements of reloading dotspacemacs on inclusion of LSP layer?

Why would a typical user frequently enable and disable LSP layer or any layer?

@sunlin7
Copy link
Contributor

sunlin7 commented Apr 6, 2021

Okay, I got your point.

This behavior change will require:

  1. Restarting spacemacse;
  2. Re-creating the spacemacs*.pdmp file if pdmp feature is actived.

Document update for changing configuration layer require restarting Spacemacs and update pdmp file will be helpful for some one doesn't know this behavior change:

doc/QUICK_START.org:81:_without restarting_ Spacemacs by pressing ~SPC f e R~.
doc/VIMUSERS.org:354:Emacs or press ~SPC f e R~. To view all layers and their documentation use
doc/DOCUMENTATION.org:494:layer from the =dotspacemacs-configuration-layers= and press ~SPC f e R~.
doc/DOCUMENTATION.org:547:To apply the modifications made in =~/.spacemacs= press ~SPC f e R~. It will
doc/DOCUMENTATION.org:567:tests are also run automatically when you synchronize with ~SPC f e R~.
....

@lebensterben
Copy link
Collaborator Author

This behavior change will require:

  1. Restarting spacemacse;

  2. Re-creating the spacemacs*.pdmp file if pdmp feature is actived.

pdump file should be already generated everytime when you reload dotspacemacs.

So there's one single step.

Does this need to be documented? No.

Because whenever you add or remove a layer, you're supposed to reload dotspacemacs.

wang-d pushed a commit to wang-d/spacemacs that referenced this pull request Jul 22, 2021
This reverts commit dae0231.

c-c++-backend is void on startup:
syl20bnr#14509 (comment)
wang-d pushed a commit to wang-d/spacemacs that referenced this pull request Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants