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

Feature request: inline options #3278

Open
1buran opened this issue May 1, 2024 · 4 comments
Open

Feature request: inline options #3278

1buran opened this issue May 1, 2024 · 4 comments

Comments

@1buran
Copy link

1buran commented May 1, 2024

It would be great to have support of inline options e.g. using setlocal command in comment will apply it in current buffer at first file opening:

// this is a normal comment line, but the next one is an inline command: 
// setlocal tabsize 2

or, if it would be easier implemented, something like emacs .dir-locals.el: special file with custom options for current dir and its decendants or type of files
e.g. file with name .micro.yaml:

filetype: json 

detect:
    filename: "\\.json$"
    header: "^\\{$"

options: 
    - tabsize: 2     
@JoeKar
Copy link
Collaborator

JoeKar commented May 1, 2024

Is the approach of Global and local settings not sufficient? The same works for whole directories too. 😉

@1buran
Copy link
Author

1buran commented May 1, 2024

Is the approach of Global and local settings not sufficient? The same works for whole directories too. 😉

hmm.. I didn't get it at the first reading of docs..

Does it work for all options? For example is it allowed to do something like this?
settings.json:

{
    "lsp.autocompleteDetails": true,
    "lsp.formatOnSave": false,
    "lsp.server": "go=gopls,php=intelephense --stdio",
    "/home/user/projects/name/huge.php": {
        "lsp.server": ""
    }
}

(disable lsp for one file)

@glupi-borna
Copy link

glupi-borna commented May 1, 2024

Note that what is actually matched against the "/home/user/projects/name/huge.php" key in your settings is the relative path to the file, as opposed to the absolute path. In this specific case, if you were in the "/home/user/projects/name" folder and typed micro huge.php at the command line, micro would open, but your settings would not be applied. Instead, you can supply the full path (micro /home/user/projects/name/huge.php), and then your settings would be applied.

If your settings were instead (off the top of my head):

{
    "lsp.autocompleteDetails": true,
    "lsp.formatOnSave": false,
    "lsp.server": "go=gopls,php=intelephense --stdio",
    "*/huge.php": {
        "lsp.server": ""
    }
}

Then any file named huge.php would have the lsp.server setting set to "".

On the topic of inline options being specified inside of files, you could totally make a plugin that does this.

@1buran
Copy link
Author

1buran commented May 1, 2024

Note that what is actually matched against the "/home/user/projects/name/huge.php" key in your settings is the relative path to the file, as opposed to the absolute path. In this specific case, if you were in the "/home/user/projects/name" folder and typed micro huge.php at the command line, micro would open, but your settings would not be applied. Instead, you can supply the full path (micro /home/user/projects/name/huge.php), and then your settings would be applied.

If your settings were instead (off the top of my head):

{
    "lsp.autocompleteDetails": true,
    "lsp.formatOnSave": false,
    "lsp.server": "go=gopls,php=intelephense --stdio",
    "*/huge.php": {
        "lsp.server": ""
    }
}

Then any file named huge.php would have the lsp.server setting set to "".

Thank you! Yeah, you are right: i faced with this weird issue - sometime the local settings were not applied, with your hints about paths puzzle is solved. I'll test this with more generic path (like you proposed).

On the topic of inline options being specified inside of files, you could totally make a plugin that does this.

hm... that's interesting, I'm not really familiar with Lua, but I really like the micro-editor, want to switch to it completely from emacs. But I'm used to using dired, magit and other emacs stuff, maybe this will encourage me to learn Lua and create plugins that will cover the lack of such functionality.

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