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

Configure kate with plasma-manager #87

Open
2 of 5 tasks
Asqiir opened this issue Mar 18, 2024 · 12 comments
Open
2 of 5 tasks

Configure kate with plasma-manager #87

Asqiir opened this issue Mar 18, 2024 · 12 comments

Comments

@Asqiir
Copy link
Contributor

Asqiir commented Mar 18, 2024

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?

  • indentation (tabs, spaces, how wide?)
  • line breaks (forced/none, at what width, \n vs \r\n)
  • The editor theme. How should the configuration react when a theme with the same filename already exist (thus, an existing file could be destroyed) or a theme with the same name (a field within the file) already exists (thus, undefined behaviour in kate could occur)?)
  • Which menus and tools to show by default, which key shortcuts to focus/unfocus/show/hide.
  • Font type, size, line-height, ... The main open question here would be: should the configuration fail if the selected font cannot be found?
@magnouvean
Copy link
Collaborator

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
Copy link
Contributor Author

Asqiir commented Mar 19, 2024

@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:

  • this custom format seems not to work with config.plasma.dataFile
  • I expect users to always replace this file with an entire new file

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
Copy link
Contributor Author

Asqiir commented Mar 19, 2024

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

@magnouvean
Copy link
Collaborator

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
Copy link
Contributor Author

Asqiir commented Mar 19, 2024

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
Copy link
Collaborator

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

@magnouvean
Copy link
Collaborator

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
Copy link
Contributor Author

Asqiir commented Mar 24, 2024

@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
Copy link
Collaborator

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

@ShalokShalom
Copy link

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

@Asqiir
Copy link
Contributor Author

Asqiir commented Apr 9, 2024

@ShalokShalom
I will take a look at it

@Asqiir
Copy link
Contributor Author

Asqiir commented May 20, 2024

@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.

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

No branches or pull requests

3 participants