Giter Club home page Giter Club logo

obsidian-completr's Introduction

Completr

This plugin provides advanced auto-completion functionality for obsidian. Legacy editor not supported.

Features

  • Latex support
    • No need to start with a \
    • Includes all MathJax commands
    • Allows \begin... completion for all environments
    • Support for inserting snippets with placeholders
  • YAML Front Matter support
    • Learns any key with any value and provides completions for them
  • Word list support
    • Load files where each line is a word
    • Performant, even with very big lists
  • Scanning your vault for words
    • Scans the current file or your whole vault to find new words which can then be suggested

Installation

Community plugin list

Browse the community plugins list and search for Completr.

Manually

  • Download main.js, styles.css and manifest.json from a release of your choice
  • Copy the three files to your vault VaultFolder/.obsidian/plugins/obsidian-completr/

After installation

  1. Restart obsidian to ensure internal hooks can get registered properly
  2. Check out the hotkeys section to further configure the plugin

Configuration

Blacklist

  • You can blacklist any suggestion by adding it to the .obsidian/plugins/obsidian-completr/blacklisted_suggestions.txt file
  • Alternatively, you can use the hotkey to blacklist the currently selected suggestion (Default Shift+D)

LaTeX commands

  • All default LaTeX commands can be found in the .obsidian/plugins/obsidian-completr/latex_commands.json file
  • You can add, remove or modify commands by editing this file
  • Replacement syntax
    • # is a placeholder for snippets
    • ~ marks the cursor position to jump to. This cannot be on the same line as a placeholder
    • \n is a newline
  • If the file contains incorrect syntax, a notice will pop up and the console will contain a more detailed error message

Hotkeys

  • All hotkeys are changeable from the hotkeys settings page
  • The "bypass" hotkeys are useful to run actions which pretend that the popup isn't open.
    • If for example your insertion key is Enter, you couldn't press enter to go to the next line while the popup is open. This is where you could use the bypass key.
    • This also allows for other modifiers to be used, for example pressing Tab might require holding Shift to move backwards. Only modifiers which are not used in the bypass keybinding will be forwarded.
    • Note: The default bypass hotkeys might be shadowed by a built-in command. Check your keybindings if they don't work.
  • If you want to change a hotkey without using any modifier, you need to use a workaround which can be found here or here, as Obsidian currently does not support this.

Example usage

Latex snippets

Latex

YAML Front Matter

Front matter

File scanning

File scanner

Two million german words loaded

Word list

Looking for word lists?

Development

  • Clone the repo to the plugins folder of an obsidian vault
  • Run npm i and npm run dev
  • Enable the plugin in obsidian

obsidian-completr's People

Contributors

eth-p avatar ethanil avatar rubbaboy avatar tth05 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

obsidian-completr's Issues

Better LaTeX Environment Detection

Thanks for this plugin! I really rely on it to write math in Obsidian. I'm thinking is it possible to improve the detection of the LaTeX environment? Currently the LaTeX provider will be triggered after any dollar sign, even in code blocks. So I think the better logic is to ignore dollar signs in inline code, code fences, and escaped dollar signs \$.

Some comments on Latex mode

So i found this great plugin (really great!) And i wanted to give u some thoughts.
As #11 I am using Extended Matjax. For that I'm using some macros that are of lenght 1, like "\f{#}{#}" instead of \frac{#}{#}. For that I assigned the minimum trigger lenght to 1. The problem is that now it appears When i dont write the "\" sign so:

  1. It would be cool if the latex completion only started after a "\".

As I added my macros directly to your source code I saw that you have included all mathjax commands... and maybe thats too much (considering I also added my macros!). So:

  1. It would be cool if there were so filtering in the latex commands. Not all are really needed. Also, if you end up adding a better way to add macros for completion, then those commands should appear first.

Thanks again for the great work!

Replacement syntax for non-LaTeX text

Hi! I really love this plugin, and the LaTeX replacement feature is great, especially the ability to tab around between different placeholder sections.

However, I was wondering if it would be possible to expand this system to work in non-LaTeX sections too. Some examples of situations that this would come in really handy are:

  • Creating a custom command that allows replacing fractions with their unicode version, where typing 1/2 would bring up the suggestion to replace it with ½.
  • Creating custom template-style sections of frontmatter that you often use, where each line could have a replacement character in it so that you can quickly insert the section and then tab through the values that need to be set.

Of course, these are just two examples I came up with, but I think this system would be very useful outside of LaTeX environments overall.

I realize that this might be slightly out of scope of the "completion" theme that the plugin currently has. But I also think that it might be a nice fit due to the fact that some LaTeX replacement commands in the plugin already have an "input" syntax that is much simpler than the output that they generate, like all of the region-related commands.

Allow for colons in autocomplete

Thanks for the plugin, works a charm.

However, small feature request allowing for colons.

User case: autocomplete for link types (using the Juggl plugin) in which I use (amongst others) the foaf link types. Aka, I use the foaf:document to highlight documents.

The autocomplete halts when typing the ':'. Would it be an option to escape the colon character?

Bug about hotkeys

The plugin seems to interfere with hotkeys. I'm on macOS, Obsidian v0.14.7. With the plugin turned on, some hotkeys like cmd + D and cmd + L don't work anymore (regardless of what commands they are binding to). I don't know if this is a bug of the plugin or Obsidian itself.

YAML tags complete support?

Hi and thx for this cool new plugin!

any chance that it can complete tags in YAML front matter?

currently obsidian is really missing that and could be super useful!

best

Z

Can't style selected tag suggestion in popup window

I can't seem to figure out how to change the style of the selected tag suggestion in popup window. I was able to style the suggested tags via

completr-suggestion-placeholder {
	color: var(--dark-orange) !important;
}

but that styled every tag suggestion except for the highlighted suggestion which is not very visible for me with my current settings:
screenshot

Plugin stopped working and changed shift-tab to tab

I noticed that my outdent stopped working. It is now the same as shift. Turning of this plugin fixed it. Also, the core functionality of the app is down also. Reload obsidian and reloaded the plugin but all not working. Didn't see anything in the console, unfortunately.

Unable to Use Arrows to Select Next/Prev Suggestion in Frontmatter

The default (and expected) use of Up or Down keys to move up or down in selection list (for frontmatter, specifically tags) doesn't work. It instead moves the cursor up or down. Perhaps a newer core update is getting in the way?

I was however able to set another keyboard shortcut to work in settings as a workaround for now.

Use \p{...} in Word Character Regex option

Hello,
First, thank you for you plugin, I can stop using Visual Studio Code for writing notes now 😄 !

The only thing is that there are a lot a diacritics in my words (such as é, ū, ṛ etc.) so I don't really want to type every single one of them in the Word Character Regex option.

But the problem is, the regex expression \p{...} doesn't seem to work here: I tried \p{L} and \p{Latin}, which should select all unicode latin letters, but it doesn't work.

Thank you for your help

Latex Autocomplete stop working after a certain document length

by the way, i used completr for months now and really happy with the Latex Autocomplete.
i used it everyday, it boost my latex typing speed.

but today, the Latex autocomplete stop working,
when write latex, it didn't trigger any pop up.

i already tested it,
i checked if there was anything that stop the autocomplete from triggering,
or if there was any loose "block" that prevent it.
but i don't think that was the problem.

and i think the Autocomplete stop working after
either it hit a certain document length or if you use too many latex equation,
because, when i delete some equation, it start working again, but when it reach a
certain length, it stop working again.

i'm using obsidian v1.0, and i didn't auto update my obsidian and completr,
so, it's not something that was caused by update.

i didn't use any other autocomplete, only latex autocomplete

my workflow always required me to work in a long document, and use Header Outline to move around the document.
therefore, it'll be unecessary to cut the document everytime the autocomplete stop working.
so, i really wish the problem could be resolved

i include the gif in the attachment,
it compared when i type at the bottom of the document vs the upper part of the document.

completr.bug.webm

Some ideas

Hi,
I would like to make some suggestions to improve your plugin for fast typing :

  1. Allow word prioritization in the list according to the frequency of the words used in the hole vault => More frequent words show at the top of the list .
    Or/and according to the frequency of the words in the
  2. Allow creating shortcut for inserting word. First choice => insertion key (enter or tab). Second, third and fourth choice => personal shortcuts or/and personal shortcuts for up/down (as it is not optimal to use arrows while typing)
  3. Allow to ban words and also to add list of blacklisted words. In my case, I've a mix of english and french in my vault due to the fact I'm writing in french, but a lot of readings are in english and I copy paste somme parts. Here it would be great to have the possibility to ban all english words (using a list provided here https://github.com/kpym/FrequencyDictionaries)

Many thanks for your work !

Enjoy your day,
Michaël

[FR] iOS support...

...would be great.
... Actually, I managed to run it in Obsidian iOS for one session (by modifying the manifest file) but the next time it did not allow me to enable it again. It was working flawlessly for that one session, though.
I wonder what allows a non-mobile app to be installed/enabled for one session and not for a second time? It happened with another plugin (Surfing; it didn't access the internet as per required though) before.

Cheers

LaTeX Provider in separate file

Hi! First of all thank you for the plugin, I'm loving it and finding it very helpful!
Since I'm using custom LaTeX commands via Extended Mathjax, I would find it really helpful if the LaTeX provider was separate to the main.js file, or perhaps even using a separate file for the custom commands (although, I do find myself changing \underbracket{#} to \underbracket{#}_{#} for example, so modifying the original provider is also quite useful IMO).
Again, thank you for all the work! 😄

Is there a way to trigger manually and not automatically?

I may be confused about how to use this. If I set the "Minimum word trigger length" to say 3, but then I only type 2 letters and hit the hotkey for "Show suggestions", the popup doesn't come up. It seems that "Minimum word trigger length" applies both to the automatic trigger and the manual hotkey trigger?

Ignore Case Not Working for Frontmatter

No matter which Word Insertion Mode I select, I can't get the auto-complete to ignore case (like getting "ob" to prompt for the tag "Obsidian")

Just wondering if a recent Obsidian update perhaps broke this, or if I'm missing something.

Feature request: An option to disable adding a newline between \begin blocks in latex

Current behaviour: after autocompleteing a latex block, the plugin automatically adds a newline between the begin and end blocks.
This is very convenient if you are writing multiline latex ($$ $$) but not if you are writing it inline ($ $).
It would be really nice if the plugin only adds a newline in multiline mode.
I encountered this problem while trying to write inline 2x2 matrices using $\begin{bmatrix} \end{bmatrix}$.

German umlauts (äöüÄÖÜß) in Obsidian and coding of german.dic

Thanks for your great plugin, which I currently have installed.

When I want to write for example "Vorwürfe", I get "Vorw�rfe" shown in the list and inserted in the text. Some UTF-8 issue, I guess.

I use the german dictionary german.dic from https://sourceforge.net/projects/germandict/ I tried to open it in Notepad++. Regardless of the coding (ansi or utf-8) I see all german umlauts as they are (äöüÄÖÜß). I converted the file to utf-8, imported it again with your plugin but the problem remained the same in Obsidian.

When I activate "ignore diacritics when filtering" and try to write "Würfelaugen" (a word, which exists in the dictionary), I didn't get it in the list.

Then I went to P:\Obsidian.obsidian\plugins\obsidian-completr\wordLists\german.dic and changed the existing file to my utf-8 coded file. And it works. ;-)

  • Windows 10, latest with 16GB RAM
  • Obsidian, latest 1.0.3
  • Your plugin, latest
  • .obsidian/plugins/obsidian-completr/wordLists/german.dic

Hope, that helps you to do something that makes it easier to use your plugin with german texts.

How to jump the cursor in latex snipppets?

A very typical example: insert \frac{}{}, I would like to move the cursor from the first bracket to the second. In your gif, I found you pressed a certain key and the cursor is directly moved. But I cannot find that key. I pressed the Tab, and nothing happens. I have to manually move the cursor.

Add option to autocomplete while maintaining case first letter

If I start typing a word and then use completr to finish that word it overrides the case of the first letter. In most cases I would prefer to maintain the case of the original word I'm typing.
image

This is also a problem in that if both upper and lowercase versions of a word are stored in completr and you start typing out the uppercase version the lowercase version will show above it. When both are shown I would expect the one that closest matches the case of the typed word to be displayed first.
image
Of course, when this is the case it might just be a better idea to merge the displayed options into one and display the suggestion as a single entry in the case that matches what the user typed. (but that's up to you)

I'm sure some people might prefer completr to override text case as it does now so having this be an option that can be changed in the settings would be ideal. However, I would argue the default behavior should be to maintain the case the user provided if possible.

[FR] either prioritize words in current file or allow current-only file provider

In Vim, I'm used to completing on nearby words using Ctrl+N and Ctrl+P. It's much more likely that I would want to repeat the words that are around in the same file and especially around the cursor.
To get something similar, I think I would need the word list to prioritize words in the current file over words in other files.

Or, even easier to implement, allow me to enable the file scanner/provider but allow me to limit it to just the current file.

Options to limit suggestions in certain contexts

Last week I threw together a plugin to suggest and format front matter tags, but when I submitted for review I was pointed in the direction of your awesome plugin!

What I'm interested in is an option to limit tags: suggestions to just tags that have been defined elsewhere in the vault. So instead of a full word list, you would just get the words that you're explicitly using as tags.

Ditto for key: suggestions. Would love to be able to just have other words that I've used as front matter keys suggested rather than a full word list.

Would you be interested in adding, or accepting PRs for, either option?

An idea for generating sentences .

Hi, completr is a good plugin for writting. And I have a idea,
Did the plugin add a function, like this website.
https://transformer.huggingface.co/doc/gpt2-large
When writting some words , press a key combination (like alt+v then alt+b),
then send the words to a website API( post a json like: {'data':"I have a dream"} ),
and recieve a json from the API (like {'sentence':[{"value","to become a better"},{"value","I want to build a country where people have a chance"},{"value",". It is the dream of all of us who have ever"}]}),
The three sentence choices will appear after the cursor.
If completr get the function, it will be amazing.
We will do writting easier than ever before With the help of AI backgroud.
Thanks!

Resources and Questions

Hello!

Thanks for developing this plugin. I thought I would offer you a link to the biggest list of frequency dictionaries I know so that you can either incorporate it or provide it as a resource to users: https://github.com/kpym/FrequencyDictionaries

In exchange, i had a feature request and a question. Question first:

  • How does this differ from the Various Complements plugin? Do you know if it is more or less performant with large files?

Feature request:

Would it be possible for us to add things to the YAML suggester? I would like to add things like my supercharged link types (usually take the form of fileClass: <type> and then <type>Type: <subtype>. I could think of others things I'd like to add (common custom breadcrumbs features) but thought I'd start there :)

[Bug] `Insert selected suggestion` doesn't work on sidepanes

Pretty self-explanatory. I've got both Tab and Esc assigned to Insert selected suggestion, and neither of them works for auto-completions in sidebar panes.

And yes, they do work perfectly on main panes, in the same instance, no changes in-between.

EDIT: clicking on the suggestion does work, so it's a thing with the hotkey.

Suggestion: Don't scan for words in URLs

Hi,

thanks for your great plugin!

My suggestion: Words in URLs are not always written correctly:

  • German Umlauts (öäüÖÄÜß) are often written as oe, ae, ue.
  • The capitalization is often not correct.
  • ...

I would suggest to irgnore words from URL to scanned_words.txt

Minimum Trigger Length

I am really enjoying completr so far! I'm wondering if a minimum-length feature could be implemented? i.e. I really only want it to trigger once the word is over 3 characters. The current word-length feature still triggers for 2-3 letter words (it filters the dictionary length)

Can't hit shift enter to go down a line when adding bullet point.

With completr on I can't hit shift + enter to go down a line. It doesn't need to be giving a suggestion for this to happen.

I'll quite often hit shift + enter to create a bullet point and then go down 1 line without deleting that bullet point. I can't do this with completr on. Instead, it behaves as if I only hit enter which causes it to delete the bullet point.

Add icons for providers

These options should be available:

  • image (if the suggestion has an icon, show both. otherwise, show provider icon)
  • image (if the suggestion has an icon, show that. otherwise, show provider icon)
  • image (always show the provider icon, even if the suggestion has an icon)
  • image (no icons at all. for those who prefer a minimalist look)

(Images taken from conversation here #44 (comment))

Option to not select the first option in the dropdown by default

I'm fine with the dropdown popping up - I just don't want any of those options to be selected until I arrow-down to them. The first option being pre-selected makes me run into the following issues (which are unfortunately making me have to disable this plugin since it's so disruptive):

  • When I hit "enter" and the completion menu is showing, it accepts that option, even though sometimes I feel like I'm already "done" writing the word and just want to insert a literal line break. When this happens, I have to undo, hit "escape" to make sure the dropdown isn't shown, and then hit "enter" to insert the linebreak.
  • I use vim-mode. When in insert mode, I will often be in the middle of typing a word and want jump back to normal mode to do some other operation, however, if the completion menu is up, the first time I hit "escape" it is registered by Obsidian as dismissing the dropdown, and leaves me in insert mode. This often leads me to getting into a habit of pressing "escape" several times just because I want to "be sure" that I'm in normal mode, and when I forget it leads me to entering text where I wish I wasn't.

I think that all of this would probably be resolved if the "focus" was not given to the completion options until the user presses the down arrow (or something like that) to intentionally go into the completion menu to choose an option.

Hopefully that makes sense! Please let me know if you need me to clarify anything.

LaTeX completion will be triggered after the certain line number

Thanks for this fantastic plugin; the LaTeX auto-completion is the killer feature to me. If I'm not mistaken, the correct logic is that LaTeX completion is only triggered in the math environment, i.e., between dollar signs. However, I found that the LaTeX completion will be triggered after the certain line number: 50 on my end. Here's a git demonstrates it

demo

Please let me know if this is a bug or the intended behavior.

Blacklist feature

While using this plugin I noticed one flaw that becomes more apparent over time especially if you're a poor speller. If you spell a word wrong that word can become indexed. If you don't notice fix this miss-spelling as it happens then often you're stuck knowing something is misspelled somewhere in all your notes but you want to know where in order to fix the issue.

I think I have a great solution for this problem though although I could see this potentially being a hard-to-implement feature. Anyways this is what I'm thinking.

Ideas for how to blacklist:

  1. When the dropdown to choose a word appears you could a little x next to each suggestion which would allow a word to be blacklisted. Or maybe hitting a certain key combo while hovering the word in the list could add it to the blacklist. Or right-clicking the the suggested word could add it to the backlist.
  2. Right-clicking a word (the actual typed word not a suggested word) could show an, add to blacklist option, in the right-click menu. If a file is already blacklisted then this should instead change to un-blacklist. Or if that's not possible maybe make the button a toggle.
  3. Add a list of blacklisted words to plugin options (I think this might exist already but I can't remember)

Once a word is blacklisted there should be ways to easily see that it's blacklisted as well as un-blacklist it.

Ideas for how to un blacklist:

  1. right-click word and click un-blacklist
  2. When typing a word show all suggestions like normal but if there is 1 or more blacklisted words then also show a button at the very bottom of the list that says show blacklisted words. Clicking this should show all blacklisted words that match the currently typed word. Then each of these should be capable of being clicked in order to add them and or un-blacklsit them.

Hopefully, that makes sense. TLDR we need an option to add and remove words from a blacklist that is really easy and intuitive for the end-user without them needing to leave to another screen.

Suggestions only based on current file. Scan of new words without restart

I really like the plugin and just have some suggestions.

  • It would be great if suggestions could optionally only be based on the currently edited file.

  • and some kind of automatic or periodic rescanning would be nice, so new words don't show up just after restart

But still a great writing tool without :)

Store word list files inside vault

Firstly, I really like your plugin. Found about it on obsidianroundup.org, and it's the best implementation of the concept that I found for Obsidian.

But, in my opinion, there's a problem with the current implementation of word list files; it uses absolute paths, even if you store the file inside the vault. It's an issue if you use Obsidian in more than one device, having to maintain a copy of the lists and adding different paths to the same file for each device.

A solution is to create a markdown file with all the words inside it, so the file scanner can add them by itself. But then suggestions with multiple words doesn't work the same, since it picks word by word. Not ideal.

Would it be possible to import the word lists to the vault and use relative paths to make the plugin completely portable? Maybe somewhere on the .obsidian folder like the css snippets, or even on a note folder like the templates' plugin, but that the scanner ignores.

Plugin doesn't work in one of my vaults

Heyo, I just updated Obsidian after not using it for a month or something like that, updated Completr in two of my vaults and noticed it stopped working in one of them.

The Chrome/Electron console doesn't have any warning or errors from any plugin, especially none from Completr.

Creating a new file with frontmatter, then writing "tags: " opens a suggestion dialogue in one of the vaults but not the other. Pressing the hotkey for opening the suggestion dialogue works in one but not the other. Even creating a new hotkey and testing that didn't yield better results.

Tag Wrangler version: 0.5.3,
Obsidian version: 0.15.8,
All other plugins disabled.

Optional Modifier for scrolling through suggestions

Hey me again :P

I recognized that I quite often get into the situation that I want to edit Items of an unordered list for which I often move the cursor up and down between items. Whenever i'm getting a suggestion pop-up I am then accidentally browsing through suggestions instead of moving to another list item.

It would be great if there was an option to need a modifier key (e.g. Ctrl) to browse the suggestions, whereas "up" and "down" by itself just jump the line up and down when the suggestions pop up is open.

Cheers. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.