diff --git a/README.md b/README.md index 83408f8..06ec601 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,16 @@ Check `init.vim` for more details. # (Optional) Copilot Follow the installation on https://github.com/github/copilot.vim, and add it ot `pack/`. You will be prompted to login from a browser, or put a 6 digit code. + +# Dependencies +After adding image and pdf support, I realised that it would be good to keep track of the +dependencies and useful packages. I'll probably create some installation script at some point. +The list is as follows: +- `poppler` for image / pdf tools. +- `ripgrep` for search. +- `fzf` for search. +- `astyle` for formatting C/C++/C#/Java. +- `black` for formatting python. +- `tlmgr` for installing LaTex packages. +- `chafa` for viewing image approximations in a terminal. +- `viu` like `chafa`, but it sends an actual image. Works with iTerm2. diff --git a/init.vim b/init.vim index 45cfb8e..878bb18 100644 --- a/init.vim +++ b/init.vim @@ -1,8 +1,8 @@ set termguicolors call plug#begin() -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' +Plug 'nvim-lualine/lualine.nvim' +Plug 'akinsho/bufferline.nvim', { 'tag': '*' } Plug 'ycm-core/YouCompleteMe', {'do': './install.py --all' } Plug 'tpope/vim-commentary' @@ -18,19 +18,20 @@ Plug 'nvim-lua/plenary.nvim' Plug 'BurntSushi/ripgrep' Plug 'nvim-telescope/telescope.nvim' Plug 'nvim-telescope/telescope-file-browser.nvim' +Plug 'nvim-lua/popup.nvim' +Plug 'nvim-telescope/telescope-media-files.nvim' Plug 'tmhedberg/SimpylFold' Plug 'jiangmiao/auto-pairs' Plug 'searleser97/cpbooster.vim' Plug 'dmdque/solidity.vim' -Plug 'rebelot/kanagawa.nvim' Plug 'morhetz/gruvbox' call plug#end() set background=dark syntax on -set mouse=nv +set mouse=a set ts=4 set sts=4 @@ -46,6 +47,7 @@ set whichwrap+=<,>,[,] let g:AutoPairsFlyMode=0 let c_no_curly_error=1 + " Better visual mode selection let g:gruvbox_invert_selection=0 let g:gruvbox_contrast_dark='hard' @@ -55,13 +57,10 @@ colorscheme gruvbox nmap imap -" I sometimes use CMD-C to copy on MacOS. -" For this to work, I map CMD-C to M-] in iTerm2. -vmap y - " Find files using Telescope command-line sugar. let mapleader = "\" nnoremap ff :Telescope find_files +nnoremap mm :Telescope media_files nnoremap fg :Telescope live_grep nnoremap fb :Telescope buffers nnoremap fh :Telescope help_tags @@ -98,16 +97,18 @@ tmap :NvimTreeToggle set clipboard=unnamed -autocmd FileType c setlocal makeprg=gcc\ '%'\ -o\ '%:r'\ -std=gnu11 -autocmd FileType cpp setlocal makeprg=g++\ '%'\ -o\ '%:r'\ -std=c++17\ -O3 +autocmd FileType c setlocal makeprg=gcc-13\ '%'\ -o\ '%:r'\ -std=gnu11 +autocmd FileType cpp setlocal makeprg=g++-13\ '%'\ -o\ '%:r'\ -std=c++17\ -O3 autocmd FileType haskell setlocal makeprg=ghc\ --make\ '%' autocmd FileType java setlocal makeprg=javac\ '%' +autocmd FileType tex setlocal makeprg=xelatex\ -interaction\ nonstopmode\ -halt-on-error\ '%' " Terminal commands set splitright -command! -nargs=* VertTerm vsplit | T +command! -nargs=* VertTerm vsplit | te " From cuklev +autocmd QuickFixCmdPost [^l]* nested cwindow function! ExecuteIfNoErrors() if len(getqflist()) == 0 call ExecuteFile() @@ -129,12 +130,18 @@ function! ExecuteFile() VertTerm node "%" elseif &filetype == "c" || &filetype == "cpp" || &filetype == "haskell" VertTerm "%:p:r" + elseif &filetype == "tex" + " Make more general, so that it doesn't require MacOS + :!open '%:r'.pdf + elseif &filetype == "pdf" || &filetype == "png" || &filetype == "jpg" || &filetype == "jpeg" + " Make more general, so that it doesn't require MacOS + :!open "%" endif endfunction " Compile & Run -map :w:make:call ExecuteIfNoErrors() -imap :w:make:call ExecuteIfNoErrors() +map :w:make:call ExecuteIfNoErrors() +imap :w:make:call ExecuteIfNoErrors() map :w:call ExecuteFile() imap :w:call ExecuteFile() @@ -156,26 +163,11 @@ let g:formatdef_custom_black = '"black -l 79 --preview"' let g:formatters_py = ['custom_black'] nmap :Autoformat +nmap :CocDiagnostics -" YCM -set completeopt-=preview -let g:ycm_confirm_extra_conf = 0 -let g:ycm_global_ycm_extra_conf = '~/.config/nvim/ycm_extra_conf.py' - +" It's annoying otherwise source ~/.config/nvim/cyrilic.vim -" vim-airline -let g:airline_theme='gruvbox' -let g:airline_powerline_fonts = 1 -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#show_close_button = 0 -let g:airline#extensions#tabline#show_tab_type = 0 -let g:airline#extensions#tabline#show_tab_nr = 0 -let airline#extensions#tabline#tabs_label = '' -let airline#extensions#tabline#show_splits = 0 -let airline#extensions#tabline#show_buffers = 0 -au User AirlineAfterInit :let g:airline_section_z = airline#section#create(['%p%%%#__accent_bold#%{g:airline_symbols.linenr}%l%#__restore__#%#__accent_bold#/%L%#__accent_bold# C:%v%#__restore__#']) - " Hide default mode set noshowmode @@ -185,29 +177,11 @@ vmap max_filesize then - return true - end - end, - - additional_vim_regex_highlighting = false, - }, -} -EOF +" YCM actually works well +set completeopt-=preview +let g:ycm_confirm_extra_conf = 0 +let g:ycm_global_ycm_extra_conf = '~/.config/nvim/ycm_extra_conf.py' + +" Add lua specific settings +" They are available in lua/init.lua +lua require('init') diff --git a/lua/init.lua b/lua/init.lua new file mode 100644 index 0000000..0a09faa --- /dev/null +++ b/lua/init.lua @@ -0,0 +1,107 @@ +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +vim.opt.fillchars = { eob = " "} + +require("toggleterm").setup() +require("nvim-tree").setup({ + sort_by = "case_sensitive", + view = { + width = 34, + }, + renderer = { + group_empty = true, + }, +}) +require("telescope").setup({ + extensions = { + media_files = { + find_cmd = "rg" + } + }, + defaults = { + file_sorter = require("telescope.sorters").get_fzy_sorter, + prompt_prefix = " >", + color_devicons = true, + + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + + layout_strategy = "horizontal", + layout_config = { + horizontal = { + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + preview_height = 0.5, + }, + }, + }, +}) + +require("telescope").load_extension("media_files") +require('lualine').setup({ + options = { + theme = 'gruvbox', + icons_enabled = true, + section_separators = {left='', right=''}, + component_separators = {left='', right=''}, + -- component_separators = { left = '', right = ''}, + -- section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +}) +require("bufferline").setup() +require"nvim-treesitter.configs".setup{ + ensure_installed = { + "c", "cpp", "python", "lua", "typescript", "javascript", "vim", "vimdoc", "query", "haskell", "cuda", "bash", "java" + }, + sync_install = false, + auto_install = false, + + highlight = { + enable = true, + -- disable slow treesitter highlight for large files + disable = function(_, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + + additional_vim_regex_highlighting = false, + }, +}