diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | coc-settings.json | 67 | ||||
-rw-r--r-- | init.lua | 8 | ||||
-rw-r--r-- | lua/autocommands/NERDTree.lua | 1 | ||||
-rw-r--r-- | lua/autocommands/buffer.lua | 4 | ||||
-rw-r--r-- | lua/autocommands/coc.lua | 9 | ||||
-rw-r--r-- | lua/autocommands/exit.lua | 38 | ||||
-rw-r--r-- | lua/autocommands/init.lua | 5 | ||||
-rw-r--r-- | lua/config.lua | 69 | ||||
-rw-r--r-- | lua/formatting.lua | 4 | ||||
-rw-r--r-- | lua/functions.lua | 124 | ||||
-rw-r--r-- | lua/maps/NERDtree.lua | 2 | ||||
-rw-r--r-- | lua/maps/auto_close.lua | 24 | ||||
-rw-r--r-- | lua/maps/buffer.lua | 6 | ||||
-rw-r--r-- | lua/maps/coc.lua | 160 | ||||
-rw-r--r-- | lua/maps/find.lua | 8 | ||||
-rw-r--r-- | lua/maps/init.lua | 7 | ||||
-rw-r--r-- | lua/maps/terminal.lua | 37 | ||||
-rw-r--r-- | lua/plugins.lua | 37 | ||||
-rw-r--r-- | lua/style.lua | 9 | ||||
-rw-r--r-- | lua/utility/autocmd.lua | 15 | ||||
-rw-r--r-- | lua/utility/git.lua | 29 | ||||
-rw-r--r-- | lua/utility/misc.lua | 8 |
23 files changed, 672 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d635cb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/plugin diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..b23b76f --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,67 @@ +{ + "coc.preferences.maxFileSize": "10000MB", + "hover.floatConfig": { + "shadow": true + }, + "Lua": { + "workspace": { + "maxPreload": 10000, + "preloadFileSize": 10000000 + }, + "runtime": { + "version": "Lua 5.1" + }, + "diagnostics": { + "enable": true, + "globals": [ + "vim" + ] + }, + "telemetry": { + "enabled": false + }, + "completion": { + "callSnippet": "Both", + "displayContext": 2, + "showWord": "Enable", + "keywordSnippet": "Both" + }, + "hint": { + "setType": true, + "paramName": "Disable", + "paramType": false + }, + "IntelliSense": { + "traceBeSetted": true, + "traceFieldInject": true + }, + "window": { + "statusBar": false + } + }, + "Lua.telemetry.enable": false, + "clangd.inlayHints.enable": false, + "rust-analyzer.restartServerOnConfigChange": true, + "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.cargo.features": "all", + "rust-analyzer.imports.granularity.enforce": true, + "rust-analyzer.imports.granularity.group": "module", + "rust-analyzer.imports.merge.glob": false, + "rust-analyzer.imports.prefix": "crate", + "rust-analyzer.inlayHints.renderColons": false, + "rust-analyzer.inlayHints.chainingHints.enable": false, + "rust-analyzer.inlayHints.parameterHints.enable": false, + "python.linting.pydocstyleEnabled": true, + "python.analysis.diagnosticMode": "workspace", + "python.analysis.typeCheckingMode": "strict", + "python.linting.pycodestyleEnabled": true, + "python.linting.pylintCategorySeverity.error": "Warning", + "python.venvPath": "~/virtualenvs", + "python.formatting.autopep8Path": "~/virtualenvs/lint/bin/autopep8", + "python.linting.pycodestylePath": "~/virtualenvs/lint/bin/pycodestyle", + "python.linting.pydocstylePath": "~/virtualenvs/lint/bin/pydocstyle", + "python.linting.pydocstyleArgs": [ + "--convention=google" + ] +} + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..055b935 --- /dev/null +++ b/init.lua @@ -0,0 +1,8 @@ +require("config") +require("plugins") +require("style") +require("formatting") +require("functions") +require("maps") +require("autocommands") + diff --git a/lua/autocommands/NERDTree.lua b/lua/autocommands/NERDTree.lua new file mode 100644 index 0000000..38213e2 --- /dev/null +++ b/lua/autocommands/NERDTree.lua @@ -0,0 +1 @@ +autocmd("VimEnter", "*", "NERDTree") diff --git a/lua/autocommands/buffer.lua b/lua/autocommands/buffer.lua new file mode 100644 index 0000000..da330c8 --- /dev/null +++ b/lua/autocommands/buffer.lua @@ -0,0 +1,4 @@ +require("utility.autocmd") + +-- autocmd("BufEnter", "*", "lua remove_hidden_windowless_buffers()") + diff --git a/lua/autocommands/coc.lua b/lua/autocommands/coc.lua new file mode 100644 index 0000000..965cca2 --- /dev/null +++ b/lua/autocommands/coc.lua @@ -0,0 +1,9 @@ +require("utility.autocmd") + +-- Highlight the symbol and its references when holding the cursor. +autocmd("CursorHold", "*", "silent call CocActionAsync('highlight')") + +augroup("coc-misc", { + -- {"FileType", "typescript,json", "setl formatexpr=CocAction('formatSelected')"}, + {"User", "CocJumpPlaceholder", "call CocActionAsync('showSignatureHelp')"}}) + diff --git a/lua/autocommands/exit.lua b/lua/autocommands/exit.lua new file mode 100644 index 0000000..8ffac46 --- /dev/null +++ b/lua/autocommands/exit.lua @@ -0,0 +1,38 @@ +require("utility.autocmd") + +-- Exit Vim if NERDTree is the only window remaining in the only tab. +--[[ +autocmd( + "BufEnter", + "*", + "if tabpagenr('$') == 1 && winnr('$') == 1 && " .. + "exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif" +) +]] + +-- Exit Vim if a terminal is the only window remaining in the only tab. +--[[ +autocmd( + "BufEnter", + "*", + "if tabpagenr('$') == 1 && winnr('$') == 1 && g:is_term_open == 1 | quit | endif" +) + +-- Exit Vim if the only windows remaining is NERDTree and terminal. +autocmd( + "BufEnter", + "*", + "if tabpagenr('$') == 1 && winnr('$') == 2 && g:NERDTree.IsOpen() && " .. + "g:is_term_open == 1 | qall | endif" +) +]] + +-- Close a single NERDTree tab. +--[[ +autocmd( + "BufEnter", + "*", + "if len(tabpagebuflist()) == 1 && bufname(tabpagebuflist()[0]) =~ \"^NERD_tree\" " .. + "| tabclose | endif" +) +]] diff --git a/lua/autocommands/init.lua b/lua/autocommands/init.lua new file mode 100644 index 0000000..23679e9 --- /dev/null +++ b/lua/autocommands/init.lua @@ -0,0 +1,5 @@ +require("autocommands.coc") +require("autocommands.exit") +require("autocommands.buffer") +require("autocommands.NERDTree") + diff --git a/lua/config.lua b/lua/config.lua new file mode 100644 index 0000000..3a6e9b4 --- /dev/null +++ b/lua/config.lua @@ -0,0 +1,69 @@ +-- Indentation +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = false +vim.o.autoindent = true +vim.o.smartindent = true + +-- Line numbers +vim.o.number = true +vim.o.relativenumber = true + +-- Misc +vim.o.conceallevel = 2 +vim.o.splitbelow = true +vim.o.shortmess = vim.o.shortmess .. "c" +vim.o.showmode = false +vim.o.formatoptions = string.gsub(vim.o.formatoptions, "[cro]", "") +vim.o.cmdheight = 2 +vim.o.errorbells = false +vim.o.scrolloff = 8 +vim.o.encoding = "UTF-8" +vim.o.fillchars = vim.o.fillchars .. "vert:█" +vim.o.colorcolumn = "90" +vim.o.signcolumn = "yes" + +-- Completion +vim.o.complete = vim.o.complete .. ",kspell" +-- vim.o.completeopt = "menuone,longest" +vim.o.wildmenu = true +vim.o.wildmode = "full" + +-- Searching +vim.o.hlsearch = false +vim.o.incsearch = true + +-- Backup +vim.o.backup = false +vim.o.writebackup = false + +-- Spell checking +vim.o.spell = false + +-- Time +vim.o.updatetime = 100 +vim.o.timeoutlen = 500 +vim.o.ttimeoutlen = 10 + +-- Style +vim.o.background = "dark" +vim.o.termguicolors = true + +vim.g.mapleader = "," + +-- Plugins +vim.g["vim_markdown_folding_disabled"] = 1 + +vim.g.rustfmt_autosave = 1 + +vim.g.nerdtree_tabs_open_on_console_startup = 1 + +vim.g.indent_blankline_char = '¦' + +-- Custom globals +vim.g.is_term_open = 0 +vim.g.terminal_height = 12 +vim.g.term_buf = 0 +vim.g.term_win = 0 + diff --git a/lua/formatting.lua b/lua/formatting.lua new file mode 100644 index 0000000..22c3a32 --- /dev/null +++ b/lua/formatting.lua @@ -0,0 +1,4 @@ +-- Clang-format +vim.g["clang_format#code_style"] = "llvm" +vim.g["clang_format#detect_style_file"] = 1 +vim.g["clang_format#auto_format"] = 1 diff --git a/lua/functions.lua b/lua/functions.lua new file mode 100644 index 0000000..12eca3a --- /dev/null +++ b/lua/functions.lua @@ -0,0 +1,124 @@ +require("utility.misc") + +function table.filter(list, predicate) + local filtered_list = {} + + for _, item in ipairs(list) do + if predicate(item) then + table.insert(filtered_list, item) + end + end + + return filtered_list +end + +function _G.check_back_space() + local col = vim.api.nvim_win_get_cursor(0)[2] + + if col == 0 then + return true + end + + return vim.api.nvim_get_current_line():sub(col, col):find("%s") and true +end + +function _G.show_documentation() + if vim.fn.index({"vim", "help"}, vim.bo.filetype) >= 0 then + vim.cmd("help " .. vim.fn.expand("<cword>")) + elseif vim.fn["coc#rpc#ready()"] then + vim.fn.CocActionAsync("doHover") + else + vim.cmd(vim.go.keywordprg .. " " .. vim.fn.expand("<cword>")) + end +end + +function _G.toggle_terminal(height) + if vim.fn.win_gotoid(vim.g.term_win) == 1 then + vim.g.is_term_open = 0 + vim.cmd("quit!") + else + vim.cmd("botright new") + + vim.cmd("resize " .. height) + + if not pcall(function() vim.cmd("buffer " .. vim.g.term_buf) end) then + vim.fn.termopen(vim.env.SHELL, {detach=0}) + + vim.g.term_buf = vim.fn.bufnr("") + + vim.o.number = false + vim.o.relativenumber = false + vim.o.signcolumn = "no" + end + + vim.cmd("startinsert!") + + vim.g.term_win = vim.fn.win_getid() + vim.g.is_term_open = 1 + + if vim.fn.exists("g:NERDTree") and vim.api.nvim_eval("g:NERDTree.IsOpen()") then + vim.cmd("NERDTreeFocus") + + vim.cmd("wincmd H") + + local width_diff = vim.fn.winwidth(0) - vim.g.NERDTreeWinSize + + vim.cmd(width_diff .. "wincmd <") + + vim.cmd("wincmd p") + + vim.fn.feedkeys("A") + end + end +end + +function _G.get_current_file() + return vim.fn.expand("%") +end + +function _G.remove_hidden_windowless_buffers() + local all_buffers = vim.fn.getbufinfo() + + local buffers = table.filter(all_buffers, function (item) + local windows = item.windows + + return #windows == 0 and item.hidden + end) + + for _, buffer in ipairs(buffers) do + vim.api.nvim_buf_delete(buffer.bufnr, { force = true }) + end +end + +function _G.close_current_buffer() + local current_buf_nr = vim.fn.bufnr() + + local all_buffers = vim.fn.getbufinfo() + + local buffers = table.filter( + all_buffers, + function(buf_info) + return buf_info.loaded == 1 + and buf_info.listed == 1 + and buf_info.bufnr ~= current_buf_nr + and not string.find(buf_info.name, "NERD_tree_") + and not string.find(buf_info.name, "term://") + end + ) + + if #buffers ~= 0 then + vim.cmd("buffer " .. buffers[1].bufnr) + else + vim.cmd("new") + end + + vim.api.nvim_buf_delete(current_buf_nr, { force = true }) + + -- Resize terminal + if vim.g.is_term_open == 1 then + vim.cmd("wincmd j") + vim.cmd("resize " .. vim.g.terminal_height) + vim.cmd("wincmd k") + end +end + diff --git a/lua/maps/NERDtree.lua b/lua/maps/NERDtree.lua new file mode 100644 index 0000000..15c933d --- /dev/null +++ b/lua/maps/NERDtree.lua @@ -0,0 +1,2 @@ +vim.api.nvim_set_keymap("n", "<C-e>", ":NERDTreeToggle<CR>", + {silent = true, noremap = true}) diff --git a/lua/maps/auto_close.lua b/lua/maps/auto_close.lua new file mode 100644 index 0000000..9da8c5f --- /dev/null +++ b/lua/maps/auto_close.lua @@ -0,0 +1,24 @@ +vim.api.nvim_set_keymap("i", "\"", + "\"\"<left>", + {silent = true, noremap = true}) + +vim.api.nvim_set_keymap("i", "'", + "''<left>", + {silent = true, noremap = true}) + +vim.api.nvim_set_keymap("i", "(", + "()<left>", + {silent = true, noremap = true}) + +vim.api.nvim_set_keymap("i", "[", + "[]<left>", + {silent = true, noremap = true}) + +vim.api.nvim_set_keymap("i", "{", + "{}<left>", + {silent = true, noremap = true}) + +vim.api.nvim_set_keymap("i", "{<CR>", + "{<CR>}<ESC>O", + {silent = true, noremap = true}) + diff --git a/lua/maps/buffer.lua b/lua/maps/buffer.lua new file mode 100644 index 0000000..99a11f6 --- /dev/null +++ b/lua/maps/buffer.lua @@ -0,0 +1,6 @@ +-- Close the current buffer +vim.api.nvim_set_keymap( + "n", + "<leader>q", ":lua close_current_buffer()<CR>", + { silent = true, noremap = true } +) diff --git a/lua/maps/coc.lua b/lua/maps/coc.lua new file mode 100644 index 0000000..d7b2b3c --- /dev/null +++ b/lua/maps/coc.lua @@ -0,0 +1,160 @@ +-- Tab completion +--[[ +vim.api.nvim_set_keymap("i", "<tab>", + "coc#pum:visible() ? coc#pum#next(1) : v:lua.check_back_space() ? '<tab>' : coc#refresh()", + {silent = true, expr = true, noremap = true}) + +vim.api.nvim_set_keymap("i", "<s-tab>", "pumvisible() ? '<C-p>' : '<C-h>'", + {expr = true, noremap = true}) +]] + +vim.cmd( +[[ +inoremap <silent><expr> <TAB> + \ coc#pum#visible() ? coc#pum#next(1): + \ v:lua.check_back_space() ? "\<Tab>" : + \ coc#refresh() + +inoremap <silent><expr> <S-TAB> + \ coc#pum#visible() ? coc#pum#prev(1): + \ v:lua.check_back_space() ? "\<Tab>" : + \ coc#refresh() +]] +) + +-- Use <c-space> to trigger completion +vim.api.nvim_set_keymap("i", "<C-space>", "coc#refresh()", + {silent = true, expr = true, noremap = true}) + +-- Make <CR> auto-select the first completion item and notify coc.nvim to +-- format on enter, <cr> could be remapped by other vim plugin +vim.api.nvim_set_keymap("i", "<CR>", + "pumvisible() ? coc#_select_confirm() : '<C-g>u<CR><c-r>=coc#on_enter()<CR>'", + {silent = true, expr = true, noremap = true}) + +-- Use `[g` and `]g` to navigate diagnostics +-- Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. +vim.api.nvim_set_keymap("n", "[g", "<Plug>(coc-diagnostic-prev)", {silent = true}) +vim.api.nvim_set_keymap("n", "]g", "<Plug>(coc-diagnostic-next)", {silent = true}) + +-- GoTo code navigation. +vim.api.nvim_set_keymap("n", "gd", "<Plug>(coc-definition)", {silent = true}) +vim.api.nvim_set_keymap("n", "gy", "<Plug>(coc-type-definition)", {silent = true}) +vim.api.nvim_set_keymap("n", "gi", "<Plug>(coc-implementation)", {silent = true}) +vim.api.nvim_set_keymap("n", "gr", "<Plug>(coc-references)", {silent = true}) + +-- Use K to show documentation in preview window. +vim.api.nvim_set_keymap("n", "K", ":call v:lua.show_documentation()<CR>", + {silent = true, noremap = true}) + +-- Symbol renaming. +vim.api.nvim_set_keymap("n", "<leader>rn", "<Plug>(coc-rename)", {}) + +vim.api.nvim_set_keymap( + "n", + "<leader>d", ":CocCommand rust-analyzer.openDocs<CR>", + { silent = true, noremap = true } +) + +-- Formatting selected code. +-- vim.api.nvim_set_keymap("x", "<leader>f", "<Plug>(coc-format-selected)", {}) +-- vim.api.nvim_set_keymap("n", "<leader>f", "<Plug>(coc-format-selected)", {}) + +-- Remap <C-f> and <C-b> for scroll float windows/popups. +vim.api.nvim_set_keymap( + "n", + "<C-f>", + "coc#float#has_scroll() ? coc#float#scroll(1) : '\\<C-f>'", + {silent = true, nowait = true, expr = true, noremap = true} +) +vim.api.nvim_set_keymap( + "n", + "<C-b>", + "coc#float#has_scroll() ? coc#float#scroll(0) : '\\<C-b>'", + {silent = true, nowait = true, expr = true, noremap = true} +) +vim.api.nvim_set_keymap( + "i", + "<C-f>", + "coc#float#has_scroll() ? '\\<c-r>=coc#float#scroll(1)\\<cr>' : '\\<Right>'", + {silent = true, nowait = true, expr = true, noremap = true} +) +vim.api.nvim_set_keymap( + "i", + "<C-b>", + "coc#float#has_scroll() ? '\\<c-r>=coc#float#scroll(0)\\<cr>' : '\\<Left>'", + {silent = true, nowait = true, expr = true, noremap = true} +) +vim.api.nvim_set_keymap( + "v", + "<C-f>", + "coc#float#has_scroll() ? coc#float#scroll(1) : '\\<C-f>'", + {silent = true, nowait = true, expr = true, noremap = true} +) +vim.api.nvim_set_keymap( + "v", + "<C-b>", + "coc#float#has_scroll() ? coc#float#scroll(0) : '\\<C-b>'", + {silent = true, nowait = true, expr = true, noremap = true} +) + +--[[ +" Applying codeAction to the selected region. +" Example: `<leader>aap` for current paragraph +xmap <leader>a <Plug>(coc-codeaction-selected) +nmap <leader>a <Plug>(coc-codeaction-selected) + +" Remap keys for applying codeAction to the current buffer. +nmap <leader>ac <Plug>(coc-codeaction) +" Apply AutoFix to problem on the current line. +nmap <leader>qf <Plug>(coc-fix-current) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server. +xmap if <Plug>(coc-funcobj-i) +omap if <Plug>(coc-funcobj-i) +xmap af <Plug>(coc-funcobj-a) +omap af <Plug>(coc-funcobj-a) +xmap ic <Plug>(coc-classobj-i) +omap ic <Plug>(coc-classobj-i) +xmap ac <Plug>(coc-classobj-a) +omap ac <Plug>(coc-classobj-a) + +" Use CTRL-S for selections ranges. +" Requires 'textDocument/selectionRange' support of language server. +nmap <silent> <C-s> <Plug>(coc-range-select) +xmap <silent> <C-s> <Plug>(coc-range-select) + +" Add `:Format` command to format current buffer. +command! -nargs=0 Format :call CocAction('format') + +" Add `:Fold` command to fold current buffer. +command! -nargs=? Fold :call CocAction('fold', <f-args>) + +" Add `:OR` command for organize imports of the current buffer. +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support. +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline. +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" Mappings for CoCList +" Show all diagnostics. +nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> +" Manage extensions. +nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> +" Show commands. +nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> +" Find symbol of current document. +nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> +" Search workspace symbols. +nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> +" Do default action for next item. +nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> +" Do default action for previous item. +nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> +" Resume latest coc list. +nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> + +]] diff --git a/lua/maps/find.lua b/lua/maps/find.lua new file mode 100644 index 0000000..5d4bfbe --- /dev/null +++ b/lua/maps/find.lua @@ -0,0 +1,8 @@ +vim.api.nvim_set_keymap("n", "<leader>p", ":Files<CR>", { silent = true, noremap = true }) + +vim.api.nvim_set_keymap("n", "<leader>b", ":Buffers<CR>", { silent = true, noremap = true }) + +vim.api.nvim_set_keymap("n", "<leader>c", ":Commits<CR>", { silent = true, noremap = true }) + +vim.api.nvim_set_keymap("n", "<leader>f", ":Ag ", { noremap = true }) + diff --git a/lua/maps/init.lua b/lua/maps/init.lua new file mode 100644 index 0000000..43f1632 --- /dev/null +++ b/lua/maps/init.lua @@ -0,0 +1,7 @@ +require("maps.coc") +require("maps.NERDtree") +require("maps.terminal") +require("maps.auto_close") +require("maps.find") +require("maps.buffer") + diff --git a/lua/maps/terminal.lua b/lua/maps/terminal.lua new file mode 100644 index 0000000..cf6f999 --- /dev/null +++ b/lua/maps/terminal.lua @@ -0,0 +1,37 @@ +vim.api.nvim_set_keymap( + "n", + "<leader>t", + ":lua toggle_terminal(vim.g.terminal_height)<CR>", + {silent = true, noremap = true} +) + +vim.api.nvim_set_keymap( + "i", + "<leader>t", + "<Esc>:lua toggle_terminal(vim.g.terminal_height)<CR>", + {silent = true, noremap = true} +) + +vim.api.nvim_set_keymap( + "t", + "<leader>t", + "<C-\\><C-n>:lua toggle_terminal(vim.g.terminal_height)<CR>", + {silent = true, noremap = true} +) + +-- Terminal go back to normal mode +vim.api.nvim_set_keymap( + "t", + "<Esc>", + "<C-\\><C-n>", + {noremap = true} +) + +vim.api.nvim_set_keymap( + "t", + ":q!", + "<C-\\><C-n>:q!<CR>", + {noremap = true} +) + + diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..4e43e14 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,37 @@ +return require("packer").startup(function(use) + use "wbthomason/packer.nvim" + + use "tpope/vim-fugitive" + + -- NERDtree + use "preservim/nerdtree" + use "ryanoasis/vim-devicons" + use "tiagofumo/vim-nerdtree-syntax-highlight" + + -- Style + use "https://git.hampusmat.com/ayu-vim" + use {"RRethy/vim-hexokinase", run = "make hexokinase"} + use "vim-airline/vim-airline" + use "lukas-reineke/indent-blankline.nvim" + + -- Coc + -- use {"neoclide/coc.nvim", branch = "release"} + use "https://github.com/HampusMat/coc.nvim" + + -- Navigation + use "christoomey/vim-tmux-navigator" + + -- Fzf + use "junegunn/fzf" + use "junegunn/fzf.vim" + + -- Formatting + use "rhysd/vim-clang-format" + + -- Markdown + use "preservim/vim-markdown" + use {"iamcco/markdown-preview.nvim", run = "cd app && yarn install"} + + -- Formatting + use "alx741/vim-rustfmt" +end) diff --git a/lua/style.lua b/lua/style.lua new file mode 100644 index 0000000..7ef1ee4 --- /dev/null +++ b/lua/style.lua @@ -0,0 +1,9 @@ +vim.cmd("colorscheme ayu") + +vim.g.ayucolor = "dark" + +vim.g.Hexokinase_highlighters = {"foreground"} + +vim.g["airline#extensions#tabline#enabled"] = 1 +vim.g["airline#extensions#tabline#formatter"] = "unique_tail_improved" + diff --git a/lua/utility/autocmd.lua b/lua/utility/autocmd.lua new file mode 100644 index 0000000..948497d --- /dev/null +++ b/lua/utility/autocmd.lua @@ -0,0 +1,15 @@ +function autocmd(event, pattern, command) + vim.cmd("autocmd " .. event .. " " .. pattern .. " " .. command) +end + +function augroup(name, autocommands) + vim.cmd("augroup " .. name) + vim.cmd("autocmd!") + + for _, autocmd_args in ipairs(autocommands) do + autocmd(unpack(autocmd_args)) + end + + vim.cmd("augroup end") +end + diff --git a/lua/utility/git.lua b/lua/utility/git.lua new file mode 100644 index 0000000..b43ccc5 --- /dev/null +++ b/lua/utility/git.lua @@ -0,0 +1,29 @@ +require("utility.misc") + +function RepositoryRoot() + local current_file = GetCurrentFile() + + if current_file == "fzf" then + return "" + end + + local super_project_path = vim.fn.system("git -C " .. Dirname(current_file) + .. " rev-parse --show-superproject-working-tree") + + if vim.v.shell_error ~= 0 then + return "" + end + + if super_project_path then + return super_project_path + end + + local toplevel_path = vim.fn.system("git -C " .. Dirname(current_file) + .. " rev-parse --show-toplevel | tr -d '\n'") + + if vim.v.shell_error ~= 0 then + return "" + end + + return toplevel_path +end diff --git a/lua/utility/misc.lua b/lua/utility/misc.lua new file mode 100644 index 0000000..04ec1fc --- /dev/null +++ b/lua/utility/misc.lua @@ -0,0 +1,8 @@ +function GetCurrentFile() + return vim.fn.expand("%") +end + +function Dirname(file_path) + return vim.fn.fnamemodify(file_path, ":p:h") +end + |