aboutsummaryrefslogtreecommitdiff
path: root/colors/base16-snazzy.vim
diff options
context:
space:
mode:
authorBonaBeavis <gordian.dziwis@gmail.com>2021-11-08 15:56:19 +0100
committerBonaBeavis <gordian.dziwis@gmail.com>2021-11-08 15:56:19 +0100
commit57b2f33e08e30bd2ba0b1935e0711d814ce44fa8 (patch)
tree8bd3c47870d6c0ac14b4337c8b7570a5b755a7ee /colors/base16-snazzy.vim
parent09138baf7a9cf3d4435bb6482acb74fdb4847bdb (diff)
Support Neovim 0.6 Diagnostic highlight groups
Diffstat (limited to 'colors/base16-snazzy.vim')
-rw-r--r--colors/base16-snazzy.vim21
1 files changed, 21 insertions, 0 deletions
diff --git a/colors/base16-snazzy.vim b/colors/base16-snazzy.vim
index 85717d4..44d4361 100644
--- a/colors/base16-snazzy.vim
+++ b/colors/base16-snazzy.vim
@@ -531,6 +531,27 @@ endif
" LSP highlighting
if has("nvim")
+ hi! link DiagnosticError ErrorSign
+ hi! link DiagnosticWarn WarningSign
+ hi! link DiagnosticInfo InfoSign
+ hi! link DiagnosticHint HintSign
+
+ hi! link DiagnosticFloatingError ErrorFloat
+ hi! link DiagnosticFloatingWarn WarningFloat
+ hi! link DiagnosticFloatingInfo InfoFloat
+ hi! link DiagnosticFloatingHint HintFloat
+
+ hi! link DiagnosticUnderlineError ErrorHighlight
+ hi! link DiagnosticUnderlineWarn WarningHighlight
+ hi! link DiagnosticUnderlineInfo InfoHighlight
+ hi! link DiagnosticUnderlineHint HintHighlight
+
+ hi! link DiagnosticsVirtualTextError ErrorSign
+ hi! link DiagnosticsVirtualTextWarning WarningSign
+ hi! link DiagnosticsVirtualTextInfo InfoSign
+ hi! link DiagnosticsVirtualTextHint HintSign
+
+ " Remove untill endif on next nvim release
hi! link LspDiagnosticsSignError ErrorSign
hi! link LspDiagnosticsSignWarning WarningSign
hi! link LspDiagnosticsSignInfo InfoSign
ghlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
extern crate getopts;
extern crate rand;

use getopts::Options;
use rand::{thread_rng, Rng};
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::Path;
use std::vec::Vec;

fn lines_from_file<P>(filename: &P) -> Result<Vec<String>, io::Error>
where
    P: AsRef<Path>,
{
    let file = try!(File::open(filename));
    let buf = BufReader::new(file);
    Ok(buf
        .lines()
        .map(|l| l.expect("Could not parse line"))
        .collect())
}

fn print_usage(program: &str, opts: Options) {
    let brief = format!("Usage: {} DICTIONARY_FILE [options]", program);
    print!("{}", opts.usage(&brief));
}

fn random_words_from_dictionary(dictionary: &Vec<String>, words: &usize) -> Vec<String> {
    let mut rng = thread_rng();
    let max_idx = dictionary.len() - 1;

    let mut vec = Vec::with_capacity(*words);
    for _ in 0..*words {
        let n: usize = rng.gen_range(0, max_idx);
        let ref token = dictionary[n];
        vec.push(token.to_string());
    }

    vec
}

#[test]
fn test_random_words_from_dictionary() {
    let test_dict = vec![
        "This".to_string(),
        "is".to_string(),
        "a".to_string(),
        "test".to_string(),
        "vector".to_string(),
    ];
    let num_words = 3;

    let new_vec = random_words_from_dictionary(&test_dict, &num_words);
    assert_eq!(new_vec.len(), 3);
}

fn main() {
    let args: Vec<String> = env::args().collect();
    let program = args[0].clone();

    let mut opts = Options::new();
    opts.optopt(
        "w",
        "",
        "number of words to use in passphrase, default is 4",
        "WORDS",
    );

    let matches = match opts.parse(&args[1..]) {
        Ok(m) => m,
        Err(f) => panic!("{}", f),
    };

    let words_opt = matches.opt_str("w");

    let input = if !matches.free.is_empty() {
        matches.free[0].clone()
    } else {
        print_usage(&program, opts);
        return;
    };

    let num_words;
    match words_opt {
        Some(x) => match x.parse::<usize>() {
            Ok(n) => num_words = n,
            Err(_e) => {
                println!("Please enter an integer for the -w flag");
                return;
            }
        },
        None => num_words = 4,
    }

    let lines;

    match lines_from_file(&input) {
        Ok(n) => lines = n,
        Err(_e) => {
            println!(
                "Cannot read file {}. Please ensure it exists and you have permission to \
                 read it.",
                input
            );
            return;
        }
    }

    let passphrase = random_words_from_dictionary(&lines, &num_words).join(" ");

    println!("{}", passphrase);
}