asottile / babi

a text editor
MIT License
396 stars 46 forks source link

Syntax highlighting is not working #243

Closed JustScreaMy closed 2 years ago

JustScreaMy commented 2 years ago

After installation the babi command is working, but the syntax highlighting is not working at all.

Some maybe useful info:

Python 3.9.5
pip 20.0.2
babi v1.5.1
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:    20.04
Codename:   focal

Screenshots

image

asottile commented 2 years ago

please include your installation instructions -- babi works best when installed in a virtualenv or with pip install --user (sudo pip install is not recommended and not supported)

JustScreaMy commented 2 years ago

i have installed it with python3.9 -m pip install babi without sudo and it is launching from .local/bin/babi so that should be alright I hope.

asottile commented 2 years ago

what is your $TERM set to?

JustScreaMy commented 2 years ago

xterm-256color

asottile commented 2 years ago

can you ls -al ~/.local/share and ls -al ~/.config/babi and echo $XDG_DATA_HOME and echo $XDG_CONFIG_HOME

JustScreaMy commented 2 years ago

ls -al ~/.local/share

krop@krop-VirtualBox:~/repos$ ls -al ~/.local/share 
total 92
drwxr-xr-x 20 krop krop 4096 May  9 20:14 .
drwxr-xr-x  5 krop krop 4096 May  9 19:12 ..
drwx------  2 krop krop 4096 Mar 16 19:01 applications
drwxrwxr-x  4 krop krop 4096 May  9 20:11 babi
drwxrwxr-x  2 krop krop 4096 Mar 17 17:38 backgrounds
drwx------  7 krop krop 4096 Mar 16 19:01 evolution
drwxr-xr-x  3 krop krop 4096 Mar 16 19:01 flatpak
drwxr-xr-x  2 krop krop 4096 Mar 16 19:01 gnome-settings-daemon
drwx------  2 krop krop 4096 May  9 19:36 gnome-shell
drwx------  2 krop krop 4096 May  9 20:18 gvfs-metadata
drwxrwxr-x  2 krop krop 4096 Mar 16 19:01 ibus-table
drwxrwxr-x  2 krop krop 4096 Mar 16 19:01 icc
drwxrwxr-x  3 krop krop 4096 Mar 25 16:19 IsolatedStorage
drwx------  2 krop krop 4096 May  9 20:15 keyrings
drwx------  2 krop krop 4096 Mar 16 19:14 nano
drwxrwxr-x  3 krop krop 4096 Mar 17 17:37 nautilus
drwxrwxr-x  3 krop krop 4096 Mar 16 19:13 pypoetry
-rw-------  1 krop krop 2433 May  9 20:14 recently-used.xbel
-rw-rw-r--  1 krop krop  218 Mar 17 17:06 recently-used.xbel.HRJEJ1
-rw-rw-r--  1 krop krop  160 Mar 16 19:01 session_migration-ubuntu
drwx------  2 krop krop 4096 Mar 16 19:01 sounds
drwxr-xr-x  3 krop krop 4096 Mar 16 19:01 tracker
drwx------  2 krop krop 4096 May  9 20:15 xorg

ls -al ~/.config/babi

ls: cannot access '/home/krop/.config/babi': No such file or directory

echo $XDG_DATA_HOME echo $XDG_CONFIG_HOME image

asottile commented 2 years ago

how about tree ~/.local/share/babi

JustScreaMy commented 2 years ago
/home/krop/.local/share/babi
├── grammar_v1
│   ├── source.arm.json
│   ├── source.asm.json
│   ├── source.batchfile.json
│   ├── source.bazel.json
│   ├── source.bazelrc.json
│   ├── source.c.json
│   ├── source.cpp.embedded.macro.json
│   ├── source.cpp.json
│   ├── source.crystal.json
│   ├── source.cs.json
│   ├── source.css.json
│   ├── source.css.scss.json
│   ├── source.dart.json
│   ├── source.diff.json
│   ├── source.dockerfile.json
│   ├── source.elixir.json
│   ├── source.fsharp.json
│   ├── source.go.json
│   ├── source.haskell.json
│   ├── source.ini.json
│   ├── source.java.json
│   ├── source.js.json
│   ├── source.js.jsx.json
│   ├── source.json.json
│   ├── source.kotlin.json
│   ├── source.lua.json
│   ├── source.makefile.json
│   ├── source.nimble.json
│   ├── source.nim.json
│   ├── source.objc.json
│   ├── source.objcpp.json
│   ├── source.perl.6.json
│   ├── source.perl.json
│   ├── source.php.json
│   ├── source.powershell.json
│   ├── source.puppet.json
│   ├── source.python.json
│   ├── source.regexp.python.json
│   ├── source.r.json
│   ├── source.rst.json
│   ├── source.ruby.gemfile.json
│   ├── source.ruby.json
│   ├── source.rust.json
│   ├── source.sassdoc.json
│   ├── source.sass.json
│   ├── source.scala.json
│   ├── source.shell.json
│   ├── source.sql.json
│   ├── source.starlark.json
│   ├── source.swift.json
│   ├── source.terraform.json
│   ├── source.toml.json
│   ├── source.ts.json
│   ├── source.tsx.json
│   ├── source.x86_64.json
│   ├── source.x86.json
│   ├── source.yaml.json
│   ├── text.git-commit.json
│   ├── text.git-rebase.json
│   ├── text.html.basic.json
│   ├── text.html.derivative.json
│   ├── text.html.erb.json
│   ├── text.html.markdown.json
│   ├── text.shell-session.json
│   ├── text.xml.json
│   └── text.xml.xsl.json
└── history

2 directories, 66 files
JustScreaMy commented 2 years ago

okay this might be stupid but I was able to resolve my issue with just reinstalling the package with some extra flags python3.9 -m pip install babi --force-reinstall --no-cache-dir, not sure where was the issue but it works now. sorry for this

asottile commented 2 years ago

seems like everything is in the right place -- let's see if it's a problem with your python interpreter. can you run this script for me?

import curses

from babi.highlight import Grammars
from babi.user_data import prefix_data, xdg_data, xdg_config
from babi.theme import Theme

def c_main(stdscr):
    return curses.COLORS, curses.can_change_color()

colors, can_change= curses.wrapper(c_main)
print(f'{colors=}')
print(f'{can_change=}')

prefix = prefix_data('grammar_v1')
print(f'{prefix=}')
xdg = xdg_data('grammar_v1')
print(f'{xdg=}')

grammars = grammars = Grammars(prefix, xdg)

python_grammar = grammars.grammar_for_scope('source.python')
print(f'{python_grammar.scope_name=}')

theme_filename = xdg_config('theme.json')
print(f'{theme_filename=}')

theme = Theme.from_filename(theme_filename)
print(f'{theme.default=}')