nix-community / plasma-manager

Manage KDE Plasma with Home Manager
MIT License
527 stars 55 forks source link

Configure kate with plasma-manager #87

Open Asqiir opened 3 months ago

Asqiir commented 3 months ago

A while ago, I started configuring kate with plasma-manager. I think it is worthwile to put my results into this project in the form of a handful new mid-level configurations.

Kate is the text editor from the KDE project and as such, its config files work in the same way as most KDE config files. This specifically implies "these are stateful config files and as such belong into the users home-environment". That is why I believe this project to be the right place for the effort.

I want to implement mid-level (high-level?) options for the following behaviour. What do you think?

magnouvean commented 3 months ago

Any new modules will always be welcome! What I would suggest is to make options which uses plasma-manager's configFile, dataFile and so on for configuration. I don't think you really need to worry about if a file already exists with the same name as adding configurations using configFile and dataFile doesn't remove already existing files, just adds new keys within the files (doing different actions based on the present files isn't really encouraged or well supported in nix anyway afaik). For the font I don't think you really need to worry about that either, that can be up to the user to make sure they have the font installed (checking this in nix is not easy either).

Also I would suggest that the module should be placed under modules/apps/kate.nix and use programs.kate prefix, just like in #69. Feel free to look for inspiration in that pr, as this will be quite similar in many ways I would assume.

Asqiir commented 3 months ago

@magnouvean When mentioning "files that might be overriden" I am talking about custom editor theme files. This is a separate file, in a format distinct from usual KDE config files.

My main points are:

As long as we expect users to stick to the kde naming scheme (<themename>.theme), and them deleting the theme from original directory everything should be fine. But is that a reasonable assumption?

Some more detailed information

Documentation from KDE The direction themes are placed in: ~/.local/share/org.kde.syntax-highlighting/syntax/ Note that the "name of a theme" is a value written within the json file, and NOT the filename.

Themes are .json files. When a user picks a theme, they might either pick one of the preinstalled themes by name or create a custom one. When there are multiple files with the same name kate cannot distinguish which one is picked.

Creating custom theme files

I would give users the option to create their own theme file. I expect the usual work flow to be:

  1. The user creates a theme file with the kate GUI program to do so
  2. The user exports the theme and saves it into their nix dotfiles
  3. The users picks the option to use that file

This workflow leaves the developer to pick the filename the theme is saved at (try not to collide with an existing file ;) ) and to pick a theme name (try not to pick one already in use, both for system-wide themes and custom ones). We could either

1) pick these values automatically, or 2) make the build fail, or 3) just make it output a warning, or 4) carry on without noticing and notifying possible errors

Asqiir commented 3 months ago

Should we add the katerc (~/.config/katerc) into the defaultResetFiles in modules/files.nix? (I'm not sure what that list does.)

magnouvean commented 3 months ago

defaultResetFiles essentially are the files which by default will be removed on each home-manager activation when using overrideConfig. In that regard I think it belongs there, and the user can exclude it being removed by adding katerc to overrideConfigExclude if they wish to do so.

I see the problem when it comes to the theme file. I think giving a warning would be a good solution there.

Asqiir commented 3 months ago

In this project, do you prefer smaller PRs (in this case, #88 is ready) or a large one when all the parts are done?

magnouvean commented 3 months ago

Smaller prs are fine, I'll check it out tomorrow hopefully

magnouvean commented 3 months ago

I have left a review now. Once the small changes are fixed I think I'll merge and we can close this (further prs can come later :))

Asqiir commented 3 months ago

@magnouvean I intended this to be an issue for ~5 smaller PRs (the todolist above), so I wouldn't close the issue for now ;)

(this PR should be good to go, I am working on the next)

magnouvean commented 3 months ago

All right, I'll merge right away and keep this open :)

ShalokShalom commented 2 months ago

I guess which plugins are enabled, could also be a worthwhile inclusion.

Asqiir commented 2 months ago

@ShalokShalom I will take a look at it

Asqiir commented 1 month ago

@ShalokShalom It's been a while, but I did take a look into it.

Which plugins are enabled isn't a general/user-wide settings, but instead it's session-wide. (If you don't know what a kate session is: yours is defined in ~/.local/share/kate/anonymous.katesession, which is equal to programs.plasma.dataFile."kate/anonymous.katesession".)

You can enable/disable plugins (per session) as follows:

    programs.plasma.dataFile."kate/anonymous.katesession" = {
      "Kate Plugins" = {
        "cmaketoolsplugin".value = false;
        "compilerexplorer".value = false;
        "eslintplugin".value = false;
        "externaltoolsplugin".value = true;
        "formatplugin".value = false;
        "katebacktracebrowserplugin".value = false;
        "katebuildplugin".value = false;
        "katecloseexceptplugin".value = false;
        "katecolorpickerplugin".value = false;
        "katectagsplugin".value = false;
        "katefilebrowserplugin".value = false;
        "katefiletreeplugin".value = true;
        "kategdbplugin".value = false;
        "kategitblameplugin".value = false;
        "katekonsoleplugin".value = true;
        "kateprojectplugin".value = true;
        "katereplicodeplugin".value = false;
        "katesearchplugin".value = true;
        "katesnippetsplugin".value = false;
        "katesqlplugin".value = false;
        "katesymbolviewerplugin".value = false;
        "katexmlcheckplugin".value = false;
        "katexmltoolsplugin".value = false;
        "keyboardmacrosplugin".value = false;
        "ktexteditorpreviewplugin".value = true;
        "latexcompletionplugin".value = true;
        "lspclientplugin".value = true;
        "openlinkplugin".value = false;
        "rainbowparens".value = false;
        "tabswitcherplugin".value = true;
        "textfilterplugin".value = true;
      };
    };

Since this is relatively straight-forward, I decided not to create new settings for this.