<commit_before>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
:set hidden
:set nobackup
:set nowritebackup

:set fileformat=unix
:set fileformats=unix,dos
:let g:netrw_dirhistmax = 0
:set noswapfile
:filetype plugin indent on
:set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
:set ignorecase
:set smartcase
:set nu
:map <C-s> :w <Enter>
:inoremap <c-s> <Esc>:update<CR>
:vmap <c-s> <Esc><c-s>gv
:autocmd BufWritePre *.* :%s/\s\+$//e
:set laststatus=2

:syntax on
:set encoding=utf-8
:set termencoding=utf-8
:set fileencoding=utf-8
:set fileencodings=utf8,ucs-bom,sjis,latin1,koi8r,cp932,cp1251,cp866,ucs-2le,default
:set hlsearch

:set cursorline
" Indent set on tab in normal and visual mode
" Do not remap TAB in normal or you'll need to remap C-I
:nnoremap <C-Tab> >>
:nnoremap <S-Tab> <<
:vnoremap <Tab> >gv
:vnoremap <S-Tab> <gv
" For insert mode let's make only reverse indent
:inoremap <S-Tab> <C-D>
:set spell spelllang=en_us

" Copy to clipboard
:set clipboard+=unnamedplus

" Auto-load rusty tags
autocmd BufRead *.* :setlocal tags=./tags;/

" C++ no namespace ident
:set cino=N-s

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
call plug#begin('~/.vim/plugged')
Plug 'rust-lang/rust.vim', {'branch': 'master'}
Plug 'joshdick/onedark.vim', {'branch': 'master'}
Plug 'dart-lang/dart-vim-plugin', {'branch': 'master'}
"LSP
Plug 'neovim/nvim-lspconfig', {'branch': 'master'}
"Auto-complete
Plug 'hrsh7th/nvim-cmp', {'branch': 'main'}
Plug 'hrsh7th/cmp-nvim-lsp', {'branch': 'main'}
Plug 'hrsh7th/cmp-buffer', {'branch': 'main'}
Plug 'hrsh7th/cmp-path', {'branch': 'main'}
Plug 'hrsh7th/cmp-nvim-lsp-signature-help', {'branch': 'main'}
Plug 'uga-rosa/cmp-dictionary', {'branch': 'main'}
Plug 'quangnguyen30192/cmp-nvim-tags', {'branch': 'main'}
" Initialize plugin system
" If you add new plugins, be sure to reload and run :PlugInstall
call plug#end()

let g:rustfmt_autosave = 0
:colorscheme onedark

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" Autocomplete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
:set signcolumn=yes
:set completeopt=longest,menuone,preview,noinsert

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" LSP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
lua <<EOF
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...)
    vim.api.nvim_buf_set_keymap(bufnr, ...)
  end

  -- Mappings.
  local opts = { noremap = true, silent = true }

  -- See `:help vim.lsp.*` for documentation on any of the below functions
  buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', 'gh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  buf_set_keymap('n', 'gH', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  buf_set_keymap('n', 'gR', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  buf_set_keymap('n', 'gA', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  buf_set_keymap('n', 'gl', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  buf_set_keymap('n', 'gL', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
end

-- Hover automatically
vim.o.updatetime = 1000
vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.lsp.buf.hover()]]

-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lspconfig = require('lspconfig')
-- Dart LSP
lspconfig.dartls.setup {
    capabilities = capabilities,
    on_attach = on_attach,
}
-- C++ LSP
lspconfig.clangd.setup {
    capabilities = capabilities,
    on_attach = on_attach,
    filetypes = { "c", "cpp" },
    single_file_support = true,
    cmd = {
        "clangd",
        "--clang-tidy",                -- enable clang-tidy diagnostics
        "--background-index",          -- index project code in the background and persist index on disk
        "--completion-style=detailed", -- granularity of code completion suggestions: bundled, detailed
    }
}
-- Python LSP
lspconfig.pyright.setup {
    capabilities = capabilities,
    on_attach = on_attach,
}
-- Rust LSP
lspconfig.rust_analyzer.setup {
    capabilities = capabilities,
    on_attach = on_attach,
    settings = {
        ["rust-analyzer"] = {
            imports = {
                merge = {
                    glob = false,
                },
            },
            cachePriming = {
                numThreads = 1,
                enable = false,
            },
            completion = {
                autoimport = {
                    enable = false
                },
            },
            checkOnSave = {
                enable = false
            },
            cargo = {
                buildScripts = {
                    enable = false
                },
            },
        }
    },
}

-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
  mapping = cmp.mapping.preset.insert({
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      else
        fallback()
      end
    end, { 'i', 's' }),
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_prev_item()
      else
        fallback()
      end
    end, { 'i', 's' }),
  }),
  sources = {
    { name = 'nvim_lsp' },
    { name = 'nvim_lsp_signature_help' },
    { name = 'tags' },
    { name = 'path', trigger_characters = { '/' } },
    { name = 'dictionary', keyword_length = 3, max_item_count = 5 },<commit_msg>nvim: make sure to auto-hover only when completition menu is not opened<commit_after>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
:set hidden
:set nobackup
:set nowritebackup

:set fileformat=unix
:set fileformats=unix,dos
:let g:netrw_dirhistmax = 0
:set noswapfile
:filetype plugin indent on
:set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
:set ignorecase
:set smartcase
:set nu
:map <C-s> :w <Enter>
:inoremap <c-s> <Esc>:update<CR>
:vmap <c-s> <Esc><c-s>gv
:autocmd BufWritePre *.* :%s/\s\+$//e
:set laststatus=2

:syntax on
:set encoding=utf-8
:set termencoding=utf-8
:set fileencoding=utf-8
:set fileencodings=utf8,ucs-bom,sjis,latin1,koi8r,cp932,cp1251,cp866,ucs-2le,default
:set hlsearch

:set cursorline
" Indent set on tab in normal and visual mode
" Do not remap TAB in normal or you'll need to remap C-I
:nnoremap <C-Tab> >>
:nnoremap <S-Tab> <<
:vnoremap <Tab> >gv
:vnoremap <S-Tab> <gv
" For insert mode let's make only reverse indent
:inoremap <S-Tab> <C-D>
:set spell spelllang=en_us

" Copy to clipboard
:set clipboard+=unnamedplus

" Auto-load rusty tags
autocmd BufRead *.* :setlocal tags=./tags;/

" C++ no namespace ident
:set cino=N-s

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
call plug#begin('~/.vim/plugged')
Plug 'rust-lang/rust.vim', {'branch': 'master'}
Plug 'joshdick/onedark.vim', {'branch': 'master'}
Plug 'dart-lang/dart-vim-plugin', {'branch': 'master'}
"LSP
Plug 'neovim/nvim-lspconfig', {'branch': 'master'}
"Auto-complete
Plug 'hrsh7th/nvim-cmp', {'branch': 'main'}
Plug 'hrsh7th/cmp-nvim-lsp', {'branch': 'main'}
Plug 'hrsh7th/cmp-buffer', {'branch': 'main'}
Plug 'hrsh7th/cmp-path', {'branch': 'main'}
Plug 'hrsh7th/cmp-nvim-lsp-signature-help', {'branch': 'main'}
Plug 'uga-rosa/cmp-dictionary', {'branch': 'main'}
Plug 'quangnguyen30192/cmp-nvim-tags', {'branch': 'main'}
" Initialize plugin system
" If you add new plugins, be sure to reload and run :PlugInstall
call plug#end()

let g:rustfmt_autosave = 0
:colorscheme onedark

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" Autocomplete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
:set signcolumn=yes
:set completeopt=longest,menuone,preview,noinsert

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" LSP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
lua <<EOF
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local cmp = require 'cmp'
function is_cmp_visible()
    local cmp = require 'cmp'
    return cmp.visible()
end

local on_attach = function(client, bufnr)
  local function buf_set_keymap(...)
    vim.api.nvim_buf_set_keymap(bufnr, ...)
  end

  -- Mappings.
  local opts = { noremap = true, silent = true }

  -- See `:help vim.lsp.*` for documentation on any of the below functions
  buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', 'gh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  buf_set_keymap('n', 'gH', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  buf_set_keymap('n', 'gR', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  buf_set_keymap('n', 'gA', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  buf_set_keymap('n', 'gl', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  buf_set_keymap('n', 'gL', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
end

-- Hover automatically
vim.o.updatetime = 1000
vim.cmd [[autocmd! CursorHold,CursorHoldI * lua if not is_cmp_visible() then vim.lsp.buf.hover() end]]

-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lspconfig = require('lspconfig')
-- Dart LSP
lspconfig.dartls.setup {
    capabilities = capabilities,
    on_attach = on_attach,
}
-- C++ LSP
lspconfig.clangd.setup {
    capabilities = capabilities,
    on_attach = on_attach,
    filetypes = { "c", "cpp" },
    single_file_support = true,
    cmd = {
        "clangd",
        "--clang-tidy",                -- enable clang-tidy diagnostics
        "--background-index",          -- index project code in the background and persist index on disk
        "--completion-style=detailed", -- granularity of code completion suggestions: bundled, detailed
    }
}
-- Python LSP
lspconfig.pyright.setup {
    capabilities = capabilities,
    on_attach = on_attach,
}
-- Rust LSP
lspconfig.rust_analyzer.setup {
    capabilities = capabilities,
    on_attach = on_attach,
    settings = {
        ["rust-analyzer"] = {
            imports = {
                merge = {
                    glob = false,
                },
            },
            cachePriming = {
                numThreads = 1,
                enable = false,
            },
            completion = {
                autoimport = {
                    enable = false
                },
            },
            checkOnSave = {
                enable = false
            },
            cargo = {
                buildScripts = {
                    enable = false
                },
            },
        }
    },
}

-- nvim-cmp setup
cmp.setup {
  mapping = cmp.mapping.preset.insert({
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = cmp.mapping(function(fallback)
      if is_cmp_visible() then
        cmp.select_next_item()
      else
        fallback()
      end
    end, { 'i', 's' }),
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if is_cmp_visible() then
        cmp.select_prev_item()
      else
        fallback()
      end
    end, { 'i', 's' }),
  }),
  sources = {
    { name = 'nvim_lsp' },
    { name = 'nvim_lsp_signature_help' },
    { name = 'tags' },
    { name = 'path', trigger_characters = { '/' } },
    { name = 'dictionary', keyword_length = 3, max_item_count = 5 },
{'fraction_non_alphanumeric': 0.24958474759875784, 'fraction_numerical': 0.006355167184227631, 'mean_word_length': 3.5672823218997363, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6463498', 'n_tokens_mistral': 5340, 'n_tokens_neox': 5215, 'n_words': 1009}