You are not logged in.

#1 2021-06-17 00:59:35

marquesine
Member
Registered: 2020-12-08
Posts: 10

[SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Terminal (st) and system are working as expected. Vim isn't.

My .vimrc:

...
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
...

localectl outputs:

System Locale: LANG=pt_BR.UTF-8
VC Keymap: br-latin1-us
X11 Layout: n/a

When I open a file that contains UTF-8 characters such as 'ãâáẽêéç...', it works.

Then I close it. Open again. It doesn't. I close and open it again: it does. So on and so on.
It began to behave like that since last time I updated all my packages (pacman -Syu).

Example: 'ação âmbito' ----> 'ação âmbito'.

Beside that, even when it is almost working as expected (like the second text snippet above), diacritic letters occupy two spaces ('í' ----> 'í ').

file file.tex on the file that contains the above examples retrieves the following:
LaTeX 2e document, Unicode text, UTF-8 text, with very long lines (590)


It is also curious that Neovim works as expected. Just like the terminal and system. But I'd rather stick with the good and old Vim, if it is possible.

[Solved] Problems with encoding and vim acting weird - didn't actually solve the problem.

Last edited by marquesine (2021-06-20 23:15:38)

Offline

#2 2021-06-17 06:03:21

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

When the display is bad, check

tr '\0' '\n' < /proc/$PID/environ

for the PID of st, shell (bash?) inside st (if you're starting vim from one) and vim and closely look at everything LC_* and LANG*

Offline

#3 2021-06-18 22:53:38

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

I checked this proc directory and didn't found any of these. Could you make a further explanation on what is PID?

I don't think it is a global variable, becase Nvim works fine.

locale:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Offline

#4 2021-06-19 05:39:31

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Eg. "pidof vim"
https://github.com/neovim/neovim/pull/935

What's interesting is that you and https://bbs.archlinux.org/viewtopic.php?id=257191 are kinda in "pt_BR.UTF-8" and what's also interesting is that your "locale" output doesn't actually reflect that - what makes the process environment all the more interesting.
Do you change LC_whatever in your shell rc?

Offline

#5 2021-06-19 15:41:27

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Yes. I actually tried to set it all to en_US.UTF-8 again.

Sometimes, even for non-americans (or non English native speakers), it is easier to set your system in the 'default' language.
For me, the only advantage to set it pt_BR is to see the day of the week and the name of the months 'correctly'.
Besides that, I think it is easier to user pacman, etc, with the English responses.

Backing to the theme of the question:

'pidof vim' returns 78100.

The problem continues.

Offline

#6 2021-06-19 15:48:14

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

'pidof vim' returns 78100.

You're supposed to use that in the environment query…

For me, the only advantage to set it pt_BR is to see the day of the week and the name of the months 'correctly'.

Add this to /etc/locale.conf

LANG="en_US.UTF-8"
LC_TIME="pt_BR.UTF-8"

and remove the shellrc changes.

But first check the environment of the process chain (your terminal, shell and vim)

Offline

#7 2021-06-19 16:42:52

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

In the following video I demonstrate what continues to happen:

https://i.imgur.com/O337Xah.mp4

Output of tr "'\0' '\n' < /proc/$PID/environ":

SHELL=/bin/bash
WINDOWID=25165830
GTK_MODULES=canberra-gtk-module
XDG_SEAT=seat0
PWD=/home/marquesine/flask
LOGNAME=marquesine
XDG_SESSION_TYPE=tty
SYSTEMD_EXEC_PID=490
XAUTHORITY=/home/marquesine/.Xauthority
WINDOWPATH=1
MOTD_SHOWN=pam
HOME=/home/marquesine
LANG=en_US.UTF-8
INVOCATION_ID=5947e28479a743dfb2c4b034ba79710b
XDG_SESSION_CLASS=user
ANDROID_HOME=/opt/android-sdk
TERM=st-256color
USER=marquesine
DISPLAY=:0
SHLVL=4
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
JOURNAL_STREAM=8:19325
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/emulator:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/spool/mail/marquesine
_=/usr/bin/vim
OLDPWD=/home/marquesine

Last edited by marquesine (2021-06-19 16:45:22)

Offline

#8 2021-06-19 17:01:18

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

And for the bash and st parenting processes?

Offline

#9 2021-06-19 17:04:20

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

seth wrote:

And for the bash and st parenting processes?

These are working just fine. None of these problems. Same for Nvim.

tr command for st:

SHELL=/bin/bash
GTK_MODULES=canberra-gtk-module
XDG_SEAT=seat0
PWD=/home/marquesine
LOGNAME=marquesine
XDG_SESSION_TYPE=tty
SYSTEMD_EXEC_PID=490
XAUTHORITY=/home/marquesine/.Xauthority
WINDOWPATH=1
MOTD_SHOWN=pam
HOME=/home/marquesine
LANG=en_US.UTF-8
INVOCATION_ID=5947e28479a743dfb2c4b034ba79710b
XDG_SESSION_CLASS=user
ANDROID_HOME=/opt/android-sdk
TERM=linux
USER=marquesine
DISPLAY=:0
SHLVL=3
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
JOURNAL_STREAM=8:19325
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/emulator:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/spool/mail/marquesine
_=/usr/local/bin/dwm

tr command for one of the bash pids:

SHELL=/bin/bash
GTK_MODULES=canberra-gtk-module
XDG_SEAT=seat0
PWD=/home/marquesine
LOGNAME=marquesine
XDG_SESSION_TYPE=tty
SYSTEMD_EXEC_PID=490
XAUTHORITY=/home/marquesine/.Xauthority
WINDOWPATH=1
MOTD_SHOWN=pam
HOME=/home/marquesine
LANG=en_US.UTF-8
INVOCATION_ID=5947e28479a743dfb2c4b034ba79710b
XDG_SESSION_CLASS=user
ANDROID_HOME=/opt/android-sdk
TERM=st-256color
USER=marquesine
DISPLAY=:0
SHLVL=3
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
JOURNAL_STREAM=8:19325
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/emulator:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/spool/mail/marquesine
_=/usr/local/bin/dwm
WINDOWID=18874374

Last edited by marquesine (2021-06-19 17:06:52)

Offline

#10 2021-06-19 19:20:14

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Can you copy the file after each cycle (so once after it was "good" and once after it was "bad") and md5sum them to see whether there's a difference in the file?

Offline

#11 2021-06-20 00:27:08

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

[marquesine@computer ~]$ vim text.txt
[marquesine@computer ~]$ cp text.txt 1.txt
[marquesine@computer ~]$ vim text.txt
[marquesine@computer ~]$ cp text.txt 2.txt
[marquesine@computer ~]$ md5sum 1.txt
bba12ca14d8dc330732fb1ef1fe2ae02  1.txt
[marquesine@computer ~]$ md5sum 2.txt
bba12ca14d8dc330732fb1ef1fe2ae02  2.txt

Just remember that 'good' is not that good.

'á' character, in example, is occupying two spaces. Like 'á  '.

Last edited by marquesine (2021-06-20 00:33:34)

Offline

#12 2021-06-20 06:57:13

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Looking at the video and your last comment: you're not actually adding spaces in the first line, they just "happen"?

a) Can you upload the file? (Any affected file, can be some dummy - just needs to show this behavior)
b) Also your vimrc
c) comment the encoding parameters in your vimr and check the default variables that vim comes up with (":set encoding" will just print that)
d) try to add "setglobal bomb" .

The X11 input isn't listed in localectl, what's the output of "setxkbmap -print -query" and do you use some input method (fcitx etc) or dead keys to enter non-ascii/accesnted glyphs?

Offline

#13 2021-06-20 20:07:18

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Yes, for the first question. 'á' occupies two characters. The spaces just happen.

a) The file of the video is here.
b) My .vimrc:

set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set number

color pablo

nnoremap <silent> <F12> :Goyo<CR>

function! NumberToggle()
    if(&number == 1)
        set number!
        set relativenumber!
    elseif(&relativenumber == 1)
        set relativenumber
        set number
    else
        set norelativenumber
        set number
    endif
endfunction

nnoremap <silent> <F1> :call NumberToggle()<CR>

map <F9> :w<bar>:!pdflatex %<CR><CR>
map <F10> :w<bar>:!pdflatex % && okular %:t:r.pdf &<CR>

map <F5> :r! date "+\%Y-\%m-\%d *" <CR>% && <%>

call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/goyo.vim'
Plug 'stanangeloff/php.vim'
call plug#end()

c) encoding=utf-8
d) After testing this procedure, the same things showed in the video continues to happen. Nothing has changed.

The X11 input isn't listed in localectl, what's the output of "setxkbmap -print -query" and do you use some input method (fcitx etc) or dead keys to enter non-ascii/accesnted glyphs?

xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+br(thinkpad)+inet(evdev)+capslock(swapescape)"      };
        xkb_geometry  { include "thinkpad(intl)"        };
};
rules:      evdev
model:      thinkpad
layout:     br
variant:    abnt2
options:    caps:swapescape

Last edited by marquesine (2021-06-20 20:13:25)

Offline

#14 2021-06-20 21:16:51

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

Try xterm.

I get this w/ an old (2019) compilation of st that I ran by acc… random chance (though I constanly get the iso rendering, not the blanks)
Can't reproduce it w/ a current one, nor xterm nor urxvt - could be the age, could be a config difference in the old st.

The file is ok, it's utf-8, no BOM but also no nonsense in it (checked w/ a hex editor) - so it's not the input.
Afaics it's also not the locale (tried xterm/urxvt w/ pt_BR.utf8)

Offline

#15 2021-06-20 22:57:23

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

xterm works perfectly.

So, just to get this right. The issue is due to and old version of st that doesn't run well with vim. Is that it?

If this is the case, how do I configure xterm to be the default terminal I open in dwm with Shift + Alt + Enter?

Also, how can I edit the appearance of xterm?

Last edited by marquesine (2021-06-20 22:59:32)

Offline

#16 2021-06-21 05:39:34

seth
Member
Registered: 2012-09-03
Posts: 49,967

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

https://wiki.archlinux.org/title/Dwm#Configuration
https://git.suckless.org/dwm/file/config.def.h.html

https://wiki.archlinux.org/title/Xterm# … e_settings
http://terminal.sexy/

I'm not sure whether it's the old st codebase of that build (you could just build the current code and see) or some config change I made between that build and the current one.

Offline

#17 2021-06-21 21:42:04

marquesine
Member
Registered: 2020-12-08
Posts: 10

Re: [SOLVED](Vim in st) Encoding works and then it stops, works, stops...

I'd just like to add here that reinstalling my st worked!

Don't have to use xterm necessarily.

cd ~
cd st
sudo make clean install

Offline

Board footer

Powered by FluxBB