├── LICENSE ├── Neovim_remixed_syntax_highlighting.jpg ├── README.md └── java.vim /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 kingDaniel2004 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Neovim_remixed_syntax_highlighting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daniel-rajakumar/NVim_Java_Highlighting/69cc7dfa0b3e760942d1d744914eb769bbc59f31/Neovim_remixed_syntax_highlighting.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NVim_Java_Highlighting 2 | 3 | Java file (before vs after) 4 | ![Image of a java file (before vs after)](https://github.com/kingDaniel2004/NVim_Java_Highlighting/blob/master/Neovim_remixed_syntax_highlighting.jpg?raw=true "Java file (before vs after)") 5 | 6 | 7 | Steps to active: 8 | 9 | 0) Go inside this cloned repo. 10 | 1) Then type this command: ```$ mv java.vim ~/.config/nvim/syntax/``` 11 | 2) Have fun :) 12 | 13 | 14 | Steps to disactive: 15 | 16 | 0) Remove the java.vim file bash command: ```$ rm ~/.config/nvim/syntax/java.vim``` 17 | 18 | 19 | 20 | 21 | 22 | - This syntax highlighting is based on Visual-Studio-Code's onedark java syntax highlighting. 23 | - BTW this code is color-coded based on onedark theme. You may change the colors according to your will. 24 | 25 | 26 | 27 | Note: 28 | This is only tested on: 29 | - Arch linux (btw i use arch) 30 | - Neovim (hopefully its works on other type of vim editors) 31 | 32 | 33 | 34 | This is a very basic syntax highlighting. but it does its job right :) 35 | 36 | Have fun java programming guys! :) 37 | 38 | 39 | -------------------------------------------------------------------------------- /java.vim: -------------------------------------------------------------------------------- 1 | 2 | " note do not change the order... 3 | " some of them are overridding privous regrex 4 | 5 | "this code made with build-in syntax regrex(and key words), and with some custome regrex(and 6 | "key words) 7 | 8 | """""""""""""""""""""""""""""""""""""""""""""""""""""""" 9 | 10 | 11 | " gruvbox (dark) 12 | "let orange = "#d65d0e" "special color for numbers 13 | "let black = "#282828" 14 | "let red = "#cc241d" 15 | "let green = "#98971a" 16 | "let yellow = "#d79921" 17 | "let blue = "#458588" 18 | "let purple = "#b16286" 19 | "let cyan = "#689d6a" 20 | "let white = "#a89984" 21 | 22 | 23 | " one dark 24 | let orange = "#d19a66" "special color for numbers 25 | let black = "#282c34" 26 | let red = "#E06C75" 27 | let green = "#98c379" 28 | let yellow = "#E5C07B" 29 | let blue = "#61AFEF" 30 | let purple = "#C678DD" 31 | let cyan = "#56B6C2" 32 | let white = "#ABB2BF" 33 | 34 | 35 | 36 | " you may chage the color according to your will :) 37 | 38 | 39 | " main color (for left over words) 40 | syn match main "\w" 41 | execute "highlight main ctermfg=4 guifg=".red 42 | 43 | " numbers 44 | syn match posNum "\d" 45 | execute "highlight posNum ctermfg=4 guifg=".orange 46 | 47 | " method names() 48 | syn match class ".\w*\((\)\@=" 49 | execute "highlight class ctermfg=4 guifg=".blue 50 | 51 | "execute "highlight names which contains numbers 52 | syn match main "\v(\a)\w*\d" 53 | execute "highlight main ctermfg=4 guifg=".red 54 | 55 | 56 | "all regrex works 57 | " /^import (+);$/mg 58 | " import \zs.*\ze 59 | " \v(^import\s+)@<=.*; 60 | 61 | " imported packages 62 | syn match importName "\v(^import\s+)@<=.*;" 63 | execute "highlight importName ctermfg=4 guifg=".yellow 64 | 65 | " import 66 | syn match importWord "import " 67 | execute "highlight importWord ctermfg=4 guifg=".purple 68 | 69 | " package name 70 | syn match packageName "\v(^package\s+)@<=.*;" 71 | execute "highlight packageName ctermfg=4 guifg=".yellow 72 | 73 | " package 74 | syn match packageWord "package " 75 | execute "highlight packageWord ctermfg=4 guifg=".purple 76 | 77 | "ex: int, double, char 78 | execute "highlight javaType ctermfg=4 guifg=".purple 79 | 80 | "ex: static, throws 81 | execute "highlight javaStorageClass ctermfg=4 guifg=".purple 82 | 83 | 84 | "class name... basically starts with caps letter 85 | syntax match ClassName display '\<\([A-Z][a-z0-9]*\)\+\>' 86 | syntax match ClassName display '\.\@<=\*' 87 | highlight link ClassName Identifier 88 | execute "highlight ClassName ctermfg=4 guifg=".yellow 89 | 90 | " Just some special color, why not? 91 | syn match print " System.out." 92 | execute "highlight print ctermfg=4 guifg=".yellow 93 | 94 | "objects (ex: String) 95 | execute "highlight Constant ctermfg=4 guifg=".yellow 96 | 97 | " class 98 | syn match javaClassDecl2 " class\> " 99 | execute "highlight javaClassDecl2 ctermfg=4 guifg=".purple 100 | 101 | " package 102 | execute "highlight javaExternal ctermfg=4 guifg=".purple 103 | 104 | "if else switch 105 | execute "highlight javaConditional ctermfg=4 guifg=".purple 106 | 107 | "while for do 108 | execute "highlight javaRepeat ctermfg=4 guifg=".purple 109 | 110 | "true flase 111 | execute "highlight javaBoolean ctermfg=4 guifg=".orange 112 | 113 | 114 | " null 115 | syn match null "\v[ =]null[; ]" 116 | execute "highlight null ctermfg=4 guifg=".orange 117 | 118 | 119 | " this super 120 | execute "highlight javaTypedef ctermfg=4 guifg=".purple 121 | 122 | " var new instanceof 123 | execute "highlight javaOperator ctermfg=4 guifg=".purple 124 | 125 | " return 126 | execute "highlight javaStatement ctermfg=4 guifg=".purple 127 | 128 | " static synchronized transient volatile final strictfp serializable 129 | execute "highlight javaStorageClass ctermfg=4 guifg=".purple 130 | 131 | "throw try catch finally 132 | execute "highlight javaExceptions ctermfg=4 guifg=".purple 133 | 134 | " assert 135 | execute "highlight javaAssert ctermfg=4 guifg=".purple 136 | 137 | " synchronized throws 138 | execute "highlight javaMethodDecl ctermfg=4 guifg=".red 139 | 140 | " extends implements interface 141 | execute "highlight javaClassDecl ctermfg=4 guifg=".red 142 | 143 | " interface 144 | execute "highlight javaClassDecl ctermfg=4 guifg=".purple 145 | 146 | " break continue skipwhite 147 | execute "highlight javaBranch ctermfg=4 guifg=".purple 148 | 149 | " public protected private abstract 150 | execute "highlight javaScopeDecl ctermfg=4 guifg=".purple 151 | 152 | 153 | """"""""""""""""""""""""""""""""""""""' 154 | " java 9... 155 | " module transitive 156 | execute "highlight javaModuleStorageClass ctermfg=4 guifg=".purple 157 | 158 | 159 | " open requires exports opens uses provides 160 | execute "highlight javaModuleStmt ctermfg=4 guifg=".yellow 161 | 162 | 163 | " to with 164 | execute "highlight javaModuleExternal ctermfg=4 guifg=".red 165 | 166 | 167 | """"""""""""""""""""""""""""""""""""""""" 168 | " lambda 169 | execute "highlight javaLambdaDef ctermfg=4 guifg=".cyan 170 | 171 | 172 | """""""""""""""""""""""""""""""""""""""""" 173 | " clone equals finalize getClass hashCode 174 | " notify notifyAll toString wait 175 | execute "highlight javaLangObject ctermfg=4 guifg=".yellow 176 | 177 | 178 | 179 | 180 | 181 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 182 | 183 | --------------------------------------------------------------------------------