2

I am working on SUSE Linux Enterprise Desktop 11 (x86_64) and I am using Vim in terminal as my editor. I have recently installed a plugin called lightline from https://github.com/itchyny/lightline.vim. The plugin uses special characters to make the status line look like this:

enter image description here

The > part of the bar is actually ► character coloured like the square next to it. The problem is that the bar, in my case, looks like this:

enter image description here

The ► character is not displayed properly, although the encoding is set to UTF-8 and all the required fonts are installed on the system (fonts for powerline). In this case the font set on terminal is Liberation Mono for Powerline.

Lightline settings in my vimrc:

set encoding=utf-8
scriptencoding utf-8

let g:lightline = {
   \ 'colorscheme': 'wombat',
   \ 'separator': {'left': "\u25B6", 'right': ''},
   \ 'subseparator': { 'left': '', 'right': ''}
   \ }

I also tried copying the ► character like this

let g:lightline = {
       \ 'colorscheme': 'wombat',
       \ 'separator': {'left': "►", 'right': ''},
       \ 'subseparator': { 'left': '', 'right': ''}
       \ }

But it manifests in the same way.

Furthermore, there is a problem with ^ characters wherever there is supposed to be whitespace.

Is there any solution for this?

omegasbk
  • 826
  • 1
  • 10
  • 24
  • 3
    Try http://vi.stackexchange.com/ – Alex K. Jul 14 '15 at 12:06
  • Wow! Did not know about that, thanks!! – omegasbk Jul 14 '15 at 12:07
  • Encoding is generally tricky, as all parts of your setup (Vim, Terminal, ...) have to agree on their respective settings. Your `set encoding=utf-8` looks good for the Vim part, so I suspect a problem with the terminal settings. What happens if you `cat` an UTF-8 file? What does `file ~/.vimrc` say on that file's encoding? – DevSolar Jul 14 '15 at 12:07
  • Ok, this is a bit strange :S I put the ► to my lightline configuration instead of \u25B6 and changed terminal encoding to Windows-1250. After I changed the terminal encoding back to UTF-8 it worked! I tried to cat the .vimrc and it shows the ► properly now. But the ^ characters are still there. – omegasbk Jul 14 '15 at 12:15
  • About '^' symbol: look to `fillchars` variable. Try something like this: `set fillchars+=stl:\ set fillchars+=stlnc:\ ` For explain read `:help fillchars`. – Alex Kroll Jul 14 '15 at 13:40
  • @omegasbk: Perhaps your Terminal was not set to UTF-8 initially. The one SLES 11 machine I have ad-hoc access to uses 8859-1 as default encoding in Terminal (yuck!). – DevSolar Jul 14 '15 at 14:23
  • @AlexKroll I am having trouble with the whitespace character. I tried with set fillchars+=stl:\ but the whitespace character is ignored for some reason, and the default ^ character is shown. I also tried putting some other character like * and it works fine. – omegasbk Jul 15 '15 at 07:03
  • @DevSolar Yeah, it seems that my terminal uses some other encoding as the default. The first thing that needs to be done in this case is to change the encoding by yourself, although it may seem that the terminal has the proper encoding by default. – omegasbk Jul 15 '15 at 07:07
  • @omegasbk Put `set fillchars+=stl:\ ` into .vimrc and restart vim it should work. – Alex Kroll Jul 15 '15 at 07:48
  • @AlexKroll `set fillchars+=stl:\ " this is a comment to prevent problems with the whitespace set fillchars+=stlnc:\ " this is a comment to prevent problems with the whitespace` I put this in my vimrc, but I still get the ^ character. If I put `set fillchars+=stl:\*` it displays * – omegasbk Jul 15 '15 at 07:57
  • @omegasbk Very strange. I've try this `set fillchars=stl:\ ` (without concatination) and this updtates statusline imidiatly with spaces. `set fillchars=stl:\ ,stlnc:\ ,vert:\|,fold:-,diff:-` – Alex Kroll Jul 15 '15 at 08:09
  • 1
    @AlexKroll I found the solution! The problem is explained in this thread http://stackoverflow.com/questions/7223309/vim-statusline-uses-carret-symbols-for-spaces-how-to-switch-to-spaces. Is says that if the stl and stlnc have the same values, they will be replaced with ^^^. It works now when I put * for stlnc and whitespace for stl. – omegasbk Jul 15 '15 at 08:19

2 Answers2

3

Following is my my_configs.vim for lightline, it works perfectly in my Fedora 26 system.

let g:lightline = { 
       \ 'colorscheme': 'wombat',
       \ }

let g:lightline = { 
       \ 'colorscheme': 'wombat',
       \ 'active': {
       \   'left': [ ['mode', 'paste'],
       \             ['fugitive', 'readonly', 'filename', 'modified'] ],
       \   'right': [ [ 'lineinfo' ], ['percent'] ]
       \ },
       \ 'component': {
       \   'readonly': '%{&filetype=="help"?"":&readonly?"\ue0a2":""}',
       \   'modified': '%{&filetype=="help"?"":&modified?"\ue0a0":&modifiable?"":"-"}',
       \   'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
       \ },
       \ 'component_visible_condition': {
       \   'readonly': '(&filetype!="help"&& &readonly)',
       \   'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
       \   'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
       \ },
       \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
       \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
       \ }   "" This is comment: I fotgot this line in my last post, just added

Sorry for my mistake, I just fixed this config. If you installed hack font from https://github.com/chrissimpkins/Hack/releases and install powerline-fonts by command "sudo dnf install powerline-fonts" in Fedora 26 system, you probably want to add the following configs to your /etc/fonts/local.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias>
    <family>Hack</family>
    <prefer>
      <family>PowerlineSymbols</family>
    </prefer>
  </alias>
</fontconfig>
Tomas
  • 41
  • 5
0

The problem was explained in this thread stackoverflow.com/questions/7223309/. It says that if the stl and stlnc have the same values, they will be replaced with ^^^. It works when you put * for stlnc and whitespace for stl.

omegasbk
  • 826
  • 1
  • 10
  • 24