vim.api.nvim_set_option("termguicolors", true) local comm = vim.api.nvim_command local bind = vim.api.nvim_set_keymap local setvar = vim.api.nvim_set_var local getvar = vim.api.nvim_get_var function hi(hi_var, hi_value) comm("hi " .. hi_var .. " " .. hi_value) end --SETTINGS vim.o.cmdheight = 1 vim.o.modifiable = true vim.o.cursorline = true vim.o.hidden = true vim.o.encoding= "utf-8" vim.o.pumheight = 10 vim.o.fileencoding = "utf-8" vim.o.ruler = true vim.o.cmdheight = 1 vim.o.mouse = "a" vim.o.splitbelow = true vim.o.splitright = true --comm("set nowrap") vim.o.conceallevel = 0 vim.o.tabstop = 2 vim.o.shiftwidth = 2 vim.o.smarttab = true vim.o.expandtab = true vim.o.smartindent = true vim.o.autoindent = true vim.o.number = true vim.o.relativenumber = true vim.o.showtabline = 2 vim.o.updatetime = 300 vim.o.lazyredraw = true vim.o.timeoutlen = 100 vim.o.clipboard = "unnamedplus" vim.o.completeopt = "menuone,noselect" vim.o.cursorcolumn = true --KEYBINDS --Colemak-DH bind fuction for hjkl [mnei]) local function cdhbind(a, b) bind('n', a:lower(), b:lower(), { noremap = true}) bind('n', a:upper(), b:upper(), { noremap = true}) bind('o', a:lower(), b:lower(), { noremap = true}) bind('o', a:upper(), b:upper(), { noremap = true}) bind('x', a:lower(), b:lower(), { noremap = true}) bind('x', a:upper(), b:upper(), { noremap = true}) end cdhbind('m', 'h') cdhbind('n', 'j') cdhbind('e', 'k') cdhbind('i', 'l') cdhbind('u', 'i') cdhbind('l', 'u') cdhbind('k', 'n') cdhbind('f', 'e') cdhbind('t', 'f') cdhbind('j', 't') bind('n', "", ":w", {noremap=true}) bind('n', "", ":resize -2", {noremap=true, silent=true}) bind('n', "", ":resize +2", {noremap=true, silent=true}) bind('n', "", ":vertical resize -2", {noremap=true, silent=true}) bind('n', "", ":vertical resize +2", {noremap=true, silent=true}) bind('v', '<', "', ">gv", {noremap=true}) bind('n', "", "q", {noremap=true}) bind('n', "", "h", {noremap=true}) bind('n', "", "j", {noremap=true}) bind('n', "", "k", {noremap=true}) bind('n', "", "l", {noremap=true}) bind('n', "", ":vsplit", {noremap=true, silent=true}) bind('n', "", ":split", {noremap=true, silent=true}) --RUN AND REPL (using vim-floaterm) function _G.CompileRun() local file = vim.fn.expand('%:p') local noext = vim.fn.expand('%:p:r') local commandMap = { ['java'] = 'java ' .. file, ['lisp'] = 'clisp ' .. file, ['python'] = 'python3 ' .. file, ['c'] = 'gcc ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' .. ' && ' .. noext .. ' && rm ' .. noext, ['rust'] = 'rustc ' .. file .. ' -o ' .. noext .. ' && ' .. noext .. ' && rm ' .. noext, ['cpp'] = 'g++ -std=c++17 ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' .. ' && ' .. noext .. ' && rm ' .. noext, ['haskell'] = 'ghc -dynamic ' .. file .. ' && ' .. noext .. ' && rm ' .. noext .. ' ' .. noext .. '.o ' .. noext .. '.hi', ['sh'] = 'sh ' .. file, ['javascript']= 'node ' .. file, ['typescript']= 'tsc ' .. file .. ' && node ' .. noext .. '.js && rm ' .. noext .. '.js' } filetype = vim.api.nvim_buf_get_option(0, "filetype") if commandMap[filetype] ~= nil then comm("FloatermNew --autoclose=0 " .. commandMap[filetype]) end end function _G.Repl() local file = vim.fn.expand('%:p') local commandMap = { ['lisp'] = 'clisp', ['python'] = 'python3', ['haskell'] = 'ghci ' .. file, ['sh'] = 'sh', ['javascript']= 'node', ['typescript']= 'ts-node', ['nix'] = 'nix repl', ['lua'] = 'lua' } filetype = vim.api.nvim_buf_get_option(0, "filetype") if commandMap[filetype] ~= nil then comm("FloatermNew " .. commandMap[filetype]) end end bind('n', "", ":call v:lua.CompileRun()", {silent=true}) bind('n', "", ":call v:lua.Repl()", {silent=true}) --PLUGINS CONFIG --nvim-tree.lua vim.g.nvim_tree_auto_ignore_ft = { "startify" } vim.g.nvim_tree_git_hl = 1 vim.g.nvim_tree_highlight_opened_files = 1 vim.g.nvim_tree_width_allow_resize = 1 require'nvim-tree'.setup { nvim_tree_auto_close = 1, nvim_tree_follow = 1, nvim_tree_lsp_diagnostics = 1 } vim.g.nvim_tree_window_picker_exclude = { ['buftype'] = { 'terminal' } } bind('n', "", ":NvimTreeToggle", {noremap=true, silent=true}) bind('n', "r", ":NvimTreeRefresh", {noremap=true, silent=true}) bind('n', "f", ":NvimTreeFindFile", {noremap=true, silent=true}) vim.o.background="dark" comm("colorscheme base16-tomorrow-night") --floaterm vim.g.floaterm_keymap_toggle = '' vim.g.floaterm_keymap_next = '' vim.g.floaterm_keymap_prev = '' vim.g.floaterm_keymap_new = '' vim.g.floaterm_gitcommit='floaterm' vim.g.floaterm_autoinsert=1 vim.g.floaterm_shell="/usr/bin/env zsh" vim.g.floaterm_position="bottom" vim.g.floaterm_width=0.99 vim.g.floaterm_height=0.6 --closetag vim.g.closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.erb,*.jsx" vim.g.closetag_xhtml_filenames = "*.xhtml,*.jsx,*.js,*.erb" vim.g.closetag_emptyTags_caseSensitive = 1 vim.g.closetag_shortcut = '>' --nerdcommenter bind('n',"","NERDCommenterToggle", {noremap=true, silent=true}) bind('n',"","NERDCommenterSexy", {noremap=true, silent=true}) --barbar bind('n', "", ":BufferPrevious", {silent=true, noremap=true}) bind('n', "", ":BufferNext", {silent=true, noremap=true}) bind('n', "", ":BufferMovePrevious", {silent=true, noremap=true}) bind('n', ">", ":BufferMoveNext", {silent=true, noremap=true}) bind('n', "", ":BufferClose", {silent=true, noremap=true}) for i = 1,8,1 do bind('n', string.format("", i), string.format(":BufferGoto %d", i), {silent=true, noremap=true}) end --presence.nvim vim.g.presence_neovim_image_text = "Ballin" vim.g.presence_main_image = "file" --treesitter-nvim require'nvim-treesitter.configs'.setup { ensure_install = "all", highlight = { enable = true, additional_vim_regex_highlighting = true, }, indent = { enable = true } } --vim-latex-live-preview vim.g.livepreview_previewer = "zathura" require'colorizer'.setup() --lsp and compe stuff i got from various places local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', {silent=true, noremap=true}) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', {silent=true, noremap=true}) buf_set_keymap('n', '', 'lua vim.lsp.buf.hover()', {silent=true, noremap=true}) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', {silent=true, noremap=true}) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', {silent=true, noremap=true}) buf_set_keymap('n', "", "lua vim.lsp.buf.formatting()", {silent=true, noremap=true}) end local servers = { "ccls", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp" } local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.resolveSupport = { properties = { 'documentation', 'detail', 'additionalTextEdits', } } local nvimlsp = require('lspconfig') for _, lsp in ipairs(servers) do nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach } end local luasnip = require 'luasnip' local cmp = require 'cmp' cmp.setup { snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, mapping = { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, [''] = function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end }, sources = { { name = 'nvim_lsp'}, { name = 'path'}, { name = 'nvim_lua'}, { name = 'luasnip'}, { name = 'calc'}, { name = 'emoji'}, { name = 'buffer'}, { name = 'look'}, }, formatting = { format = require('lspkind').cmp_format({ with_text = true, menu = ({ buffer = "[Buffer]", nvim_lsp = "[LSP]", luasnip = "[LuaSnip]", nvim_lua = "[Lua]", latex_symbols = "[Latex]", }) }), }, } cmp.setup.cmdline('/', { sources = { { name = 'buffer' } } }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(':', { sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) --bind("i", "", "v:lua.tab_complete()", {expr = true, silent = true}) --bind("s", "", "v:lua.tab_complete()", {expr = true, silent = true}) --bind("i", "", "v:lua.s_tab_complete()", {expr = true, silent = true}) --bind("s", "", "v:lua.s_tab_complete()", {expr = true, silent = true}) --bind("i", "", "compe#confirm('')", {expr = true, silent = true}) comm("set shortmess+=c") --STATUSLINE comm("set noruler") vim.o.laststatus = 2 local function mode() local mode_map = { ['n'] = 'normal ', ['v'] = 'visual ', ['V'] = 'v·line ', [''] = 'v·block ', ['s'] = 'select ', ['S'] = 's·line ', [''] = 's·block ', ['i'] = 'insert ', ['Rv'] = 'v·replace ', ['c'] = 'command ', ['!'] = 'shell ', ['t'] = 'terminal ' } local m = vim.api.nvim_get_mode().mode if mode_map[m] == nil then return m end return mode_map[m] end hi("Light", "guibg=#c5c8c6 guifg=#1d1f21") hi("Dark", "guibg=#1d1f21 guifg=#c5c8c6") hi("Gray", "guifg=#1d1f21 guibg=#b294bb") local function git() local branch = io.popen([[git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n']]):read("*a") return string.len(branch) > 0 and ' '.. branch or '' end local statusline = { '%#Light# ', mode():upper() .. ' ', '%#Dark#', string.len(git()) > 0 and ' ' .. git() .. ' ' or '', '%#Gray# ', '%f ', '%#Light#', '%=', '%#Dark# ', '%y ', '%#Light# ', '%p%% ', ' ', '%l/%L ', ' ', '%c ' } vim.o.statusline = table.concat(statusline) vim.g.tex_flavor = "latex" comm("set syntax=off")