Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is as highlighted like an operator and not a keyword? #486

Closed
mweber15 opened this issue Oct 23, 2022 · 1 comment
Closed

Why is as highlighted like an operator and not a keyword? #486

mweber15 opened this issue Oct 23, 2022 · 1 comment

Comments

@mweber15
Copy link

This has been done this way for a very long time (2111663), but it's unclear (to me) why. The result is that Vim highlighting doesn't match highlighting within the book, and possibly other places as well, which is a bit jarring. If I change this then I get the result that I expect in the specific scenario where I noticed it, but I assume there's a good reason for the current behavior.

  • rust.vim version:
% pwd
/home/matt/.vim/pack/plugins/start/rust.vim
% git log -1 --oneline
1cdc5cb (HEAD -> master, origin/master, origin/HEAD) Ignore `For more information` line

Steps to reproduce:
Use the as keyword anywhere.

Expected vs. actual behavior:

Expected: keyword highlighting
image

Actual: operator highlighting
image

Paste debugging info from the Rust Vim plugin via one of the following
commands: :RustInfo, :RustInfoToClipboard, or :RustInfoToFile <filename>.

rust.vim Global Variables:

let g:ftplugin_rust_source_path = v:null
let g:loaded_syntastic_rust_cargo_checker = v:null
let g:loaded_syntastic_rust_filetype = v:null
let g:loaded_syntastic_rust_rustc_checker = v:null
let g:rust_bang_comment_leader = v:null
let g:rust_cargo_avoid_whole_workspace = v:null
let g:rust_clip_command = v:null
let g:rust_conceal = v:null
let g:rust_conceal_mod_path = v:null
let g:rust_conceal_pub = v:null
let g:rust_fold = v:null
let g:rust_last_args = v:null
let b:rust_last_args = []
let g:rust_last_rustc_args = v:null
let b:rust_last_rustc_args = []
let g:rust_original_delimitMate_excluded_regions = v:null
let g:rust_playpen_url = v:null
let g:rust_prev_delimitMate_quotes = v:null
let g:rust_recent_nearest_cargo_tol = v:null
let g:rust_recent_root_cargo_toml = v:null
let g:rust_recommended_style = v:null
let g:rust_set_conceallevel = v:null
let g:rust_set_conceallevel=1 = v:null
let g:rust_set_foldmethod = v:null
let g:rust_set_foldmethod=1 = v:null
let g:rust_shortener_url = v:null
let g:rustc_makeprg_no_percent = v:null
let g:rustc_path = v:null
let g:rustfmt_autosave = 1
let g:rustfmt_autosave_if_config_present = v:null
let g:rustfmt_command = 'rustfmt'
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
let g:rustfmt_options = ''
let g:syntastic_extra_filetypes = ['rust']
let g:syntastic_rust_cargo_fname = v:null
rustfmt 1.5.1-stable (a55dd71 2022-09-19)

rustc 1.64.0 (a55dd71d5 2022-09-19)

cargo 1.64.0 (387270bc7 2022-09-16)


VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Sep 16 2022 00:00:00)
Included patches: 1-475
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +cursorshape       +job               +mouse_urxvt       +signs             +user_commands
+arabic            +dialog_con_gui    +jumplist          +mouse_xterm       +smartindent       +vartabs
+autocmd           +diff              +keymap            +multi_byte        +sodium            +vertsplit
+autochdir         +digraphs          +lambda            +multi_lang        +sound             +vim9script
-autoservername    +dnd               +langmap           -mzscheme          +spell             +viminfo
+balloon_eval      -ebcdic            +libcall           +netbeans_intg     +startuptime       +virtualedit
+balloon_eval_term +emacs_tags        +linebreak         +num64             +statusline        +visual
+browse            +eval              +lispindent        +packages          -sun_workshop      +visualextra
++builtin_terms    +ex_extra          +listcmds          +path_extra        +syntax            +vreplace
+byte_offset       +extra_search      +localmap          +perl/dyn          +tag_binary        +wildignore
+channel           -farsi             +lua/dyn           +persistent_undo   -tag_old_static    +wildmenu
+cindent           +file_in_path      +menu              +popupwin          -tag_any_white     +windows
+clientserver      +find_in_path      +mksession         +postscript        -tcl               +writebackup
+clipboard         +float             +modify_fname      +printer           +termguicolors     +X11
+cmdline_compl     +folding           +mouse             +profile           +terminal          -xfontset
+cmdline_hist      -footer            +mouseshape        -python            +terminfo          +xim
+cmdline_info      +fork()            +mouse_dec         +python3/dyn       +termresponse      +xpm
+comments          +gettext           +mouse_gpm         +quickfix          +textobjects       +xsmp_interact
+conceal           -hangul_input      -mouse_jsbterm     +reltime           +textprop          +xterm_clipboard
+cryptv            +iconv             +mouse_netterm     +rightleft         +timers            -xterm_save
+cscope            +insert_expand     +mouse_sgr         +ruby/dyn          +title             
+cursorbind        +ipv6              -mouse_sysmouse    +scrollbind        +toolbar           
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -L. -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/vim90/.package_note-vim-9.0.475-1.fc36.x86_64.ld -L/usr/local/lib -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lSM -lICE -lm -lselinux -lncurses -lcanberra -lsodium -lacl -lattr -lgpm -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -fstack-protector-strong -L/usr/local/lib -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc 
@chris-morgan
Copy link
Member

Because it is an operator. It’s an infix boolean operator, expr "as" ty, ty "as" ty or path "as" ident (though this last is a little more keywordy than the other two) depending on the context. See also :help group-name which gives sizeof as an example of a good candidate for Operator.

I started using Rust a few months after this change was made, and I would have made this very change myself had it not already been done.

Look, one could make it rustOperatorKeyword to allow people to more readily highlight keyword operators differently, but it should still default link to Operator.

@chris-morgan chris-morgan closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants