neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
574 stars 51 forks source link

Shorten the Python Interpreter details in statusline? #187

Open aasutossh opened 4 years ago

aasutossh commented 4 years ago

Hi, I am using airline and conda to manage envs. The python interpreter looks like this Python 3.8.2 64-bit ('my-awesome-project': conda). Which is very long (in vsp mode it takes almost all space in the statusline). I'd like to only have my-awesome-project: 3.8.2 or similar in the line.

Is this doable now? Thank you.

chemzqm commented 4 years ago

PR welcome

NullSense commented 3 years ago

@chemzqm I might want to take this up, I haven't looked through any code yet of the project. Could you give some pointers on where to start looking?

chemzqm commented 3 years ago

https://github.com/neoclide/coc-python/blob/master/src/interpreter/display/index.ts#L69

patnr commented 3 years ago

A workaround is to hack the string in the airline extension, replacing airline#extensions#coc#get_status() by the following. It's only operational on conda environments.

function! airline#extensions#coc#get_status() abort
  " Shorten text for windows < 91 characters
  let venv = airline#util#shorten(get(g:, 'coc_status', ''), 91, 9)
  " Shorten 'Python 3.8.5 64-bit ('MYENV': conda)' to 'MYENV'
  if venv =~ "conda"
    let venv = substitute(venv, "Py.*('\\(.*\\)':.*", "\\1", "")
  endif
  return venv
endfunction