Emacs: How can I customize eglot to make it autocomplete \ac{} when in latex-mode? - emacs

I'm experimentinng with eglot and digestif as my completion framework for LaTEX on emacs. I'm starting to understand how it works for \cite{} and \ref{}, but I use acronyms profusely and would like to have hints for my acronyms.
Is there any way to add a function to complete inside a \ac{}?

Related

disable sql-mode autocompletion in emacs

I'm trying to write my pl/sql code in following way: id_sel then hit TAB or Enter and I've got id_select completion! It works with any ...sel word. I think it is an sql-mode feature. How to disable this?
It's all about abbrev-mode.
abbrev-mode by default uses .abbrev_defs file, that utilizes sql-mode-abbrev-table variable from sql-mode.sql.

Emacs autocomplete doesn't update C++ suggestions

I have autocomplete set up for Emacs, and for elisp, it works perfectly fine. I have it set up to use ctags for completion in C++ files and the suggestions appear as expected. However, it doesn't update suggestions as I type. For example, if I type:
vector<string> s;
s.
it suggests 'at'. However, if I add to it so that it looks like:
vector<string> s;
s.push
the suggestion doesn't update and still displays 'at' as the first suggestion, rather than 'push_back'.
I am an Emacs novice and have virtually no elisp knowledge, and was wondering how I can configure autocomplete so that it updates suggestions for C++ as I type.

Ask Emacs to create function (e.g. Eclipse/IntelliJ suggest/fix feature)

I am editing Clojure code in Emacs23, I am pretty new and I was wondering if there is a feature in Emacs to create missing function? It would be similar to Ctrl+1 in Emacs or Alt+Insert => Create method.
what kind of "missing function" do you want to create? If you want to create empty function, then you can use any of snippet expansion packages, for example, yasnippet...
P.S. you can look onto my snippets for clojure...

Emacs: Enter commands like in gedit

in gedit it's possible to define so-called "snippets" for simpler input.
For example, there is a snippet while. This means: If you type while -> (-> stands for tab key). And gedit automatically converts it to the following (including correct indentation):
while (condition){
}
In vim (in conjunction with latex-suite) I saw the following: If you type (, vim inserts just a (. If you type ( a second time, vim automatically converts it to \left( \right).
I found abbrev-mode but this mode doesn't place the cursor properly (i.e. between parentheses or inside the while loop).
I managed to create custom emacs keybindings/macros that do just the same (without having to press the tab key), so I know it's possible.
However, is there already and package where you can define such "snippets" without much effort? Or are there even any serious reasons not to use such things?
See yasnippet. It provides snippets for most major languages, and it is easy to add new ones or modify the old ones.
Yes, yasnippet is probably the way to go. But make sure you learn the major mode you're using for your editing - when writing in LaTeX, learn auctex. Major modes can contain functionality that makes some snippets pointless, and do the same thing even better. So instead of using a begin/end-snippet in a LaTeX buffer, try C-c C-e in auctex. Etc :)
Don't forget abbrev-mode.

Is there any way to enable code completion for Perl in vim?

Surprisingly as you get good at vim, you can code even faster than standard IDEs such as Eclipse. But one thing I really miss is code completion, especially for long variable names and functions.
Is there any way to enable code completion for Perl in vim?
Ctrl-P (Get Previous Match) and Ctrl-N (Get Next Match) are kind of pseudo code completion. They basically search the file (Backwards for Ctrl-P, Forwards for Ctrl-N) you are editing (and any open buffers, and if you are using TAGS anything in your TAG file) for words that start with what you are typing and add a drop down list. It works surprisingly well for variables and function names, even if it isn't intellisense. Generally I use Ctrl-P as the variable or function I am looking for is usually behind in the code. Also if you keep the same copy of Vim open, it will search the files you have previously opened.
Vim 7 supports omni completion.
For example, I have this in my vimrc
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
and then, when I press Ctrl-X Ctrl-O in Insert mode, I get a dropdown list of autocomplete possibilities.
Here's an omnicfunc for perl. No idea how well it works though.
Well, Vim's generic completion mechanism is surprisingly good, just using Ctrl-N in insert mode. Also, line completion is very handy, using C-x C-l.
Also check out this vim script for perl.
The standard Ctrl+N and Ctrl+P works even better if you add the following to your ~/.vim/ftplugin/perl.vim file:
set iskeyword+=:
Then it will autocomplete module names, etc.
The .vimrc clip in one of the other answers is slightly wrong. To turn your tab key into an auto-complete key, use this code:
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
You can find this, and tons of other vim tricks in this thread at Perlmonks--which links to even more threads with lots more customizations.
You should look at the SuperTab plugin:
http://www.vim.org/scripts/script.php?script_id=1643
It let's you do completion (either the OmniCompletion or the regular completion) using tab and shift-tab instead of ^N and ^P.
https://github.com/c9s/perlomni.vim
Ctrl+N
This is explained in the Perl Hacks book, along with how to do Package completion. Highly recommended.