4coder » Forums » How to get autocomplete in .txt ?
areriff
Mevius
13 posts

Love dark theme. Use it for everything. OS, browser, webpages, IDE, desktop background.

#14075 How to get autocomplete in .txt ?
9 months ago Edited by Mevius on Jan. 22, 2018, 9:11 a.m. Reason: Initial post

From time to time I will be working on a single plain text file to write articles or essays. I really want 4coder code autocomplete feature to work within that txt file as well.

I watched the tutorial on using 4coder_default_hooks.cpp to modify type of file 4coder will handle. I tried to add another if condition to put txt files to it but it still treated txt file just like any other file that are not originally in 4coder_default_hooks.cpp

Currently the only way to implement this feature that I found is by adding .txt to extension section inside config.4coder. The result is colorful txt with some words highlighted when it match any C++ keywords in the typical essay txt file.

The official documentation is not clear. I may have missed something (big).

How to correctly get words autocomplete without C++ keywords auto highlight?

I just bought full version yesterday though have been the using the demo since it released. I'm new to customization.

New to C family.
mrmixer
Simon Anciaux
468 posts
#14077 How to get autocomplete in .txt ?
9 months ago Edited by Simon Anciaux on Jan. 23, 2018, 3:02 p.m. Reason: I'm wrong !

EDIT: look at the reply below, what I said was wrong.

I don't think there is a setting for that. I believe that the thing that populate the autocomplete list is the "treat as code" flags on the buffer. What you could do with the custom layer is create a new language context with no keywords in it.

Look at the default_file_settings function in 4coder_default_hooks.cpp and files in the languages folder.
nicoco
nj
25 posts
#14088 How to get autocomplete in .txt ?
9 months ago

Afaik the "problem" is that the command `word_complete` is not bound to a key when the file opened is not marked as "code file".
The solution would be simply to rebind `word_complete`, e.g.
1
bind(context, '\t', MDFR_NONE,  word_complete);
on the key map that is used for non-code files as well.
areriff
Mevius
13 posts

Love dark theme. Use it for everything. OS, browser, webpages, IDE, desktop background.

#14093 How to get autocomplete in .txt ?
9 months ago

Which file do I look for the place that set the command "word_complete"?

I found the code mentioned in "4coder_generated/remapping.h". Is it the right one?

Do I just edit that file directly and recompile?


New to C family.
areriff
Mevius
13 posts

Love dark theme. Use it for everything. OS, browser, webpages, IDE, desktop background.

#14094 How to get autocomplete in .txt ?
9 months ago

mrmixer
EDIT: look at the reply below, what I said was wrong.

I don't think there is a setting for that. I believe that the thing that populate the autocomplete list is the "treat as code" flags on the buffer. What you could do with the custom layer is create a new language context with no keywords in it.

Look at the default_file_settings function in 4coder_default_hooks.cpp and files in the languages folder.


I tried editing default_file_settings in the 4coder_default_hooks.cpp directly by:
1. adding another if statement to match "txt" extension. Nothing happen after recompile.
2. adding another condition to
1
if (match(ext, "cpp") || match(ext, "h")...
into
1
if (match(ext, "cpp") || match(ext, "h") || match(ext, "txt")...
Recompile that one too and nothing happen.

Sorry for asking this noobies question. I'm new.

New to C family.
Mr4thDimention
Allen Webster
424 posts / 2 projects

Heyo

#14096 How to get autocomplete in .txt ?
9 months ago

nicoco
Afaik the "problem" is that the command `word_complete` is not bound to a key when the file opened is not marked as "code file".
The solution would be simply to rebind `word_complete`, e.g.
1
bind(context, '\t', MDFR_NONE,  word_complete);
on the key map that is used for non-code files as well.


This is the best route. Treating .txt as code will lead to problems, but you can just bind word complete to a text file. The reason this isn't already done is because in text files I sometimes actually want to insert tabs, and didn't want a different key combo for word complete.

You will want to edit 4coder_generated/remapping.h

Bring the
1
bind(context, '\t', MDFR_NONE,  word_complete);
into the section for mapid_file.
Mr4thDimention
Allen Webster
424 posts / 2 projects

Heyo

#14098 How to get autocomplete in .txt ?
9 months ago

Also note that this fix assumes you are using the default bindings. If you are maintaining your own key map, you will just have to make the equivalent change to that map.
areriff
Mevius
13 posts

Love dark theme. Use it for everything. OS, browser, webpages, IDE, desktop background.

#14117 How to get autocomplete in .txt ?
9 months ago

thanks. It works :-)

New to C family.