diff options
author | nathan11 <thenathansmithsmith@gmail.com> | 2023-07-25 00:52:07 -0600 |
---|---|---|
committer | nathan11 <thenathansmithsmith@gmail.com> | 2023-07-25 00:52:07 -0600 |
commit | 0f8c62f2d18fd86e2bad01a33e5e9beb4e2ef77b (patch) | |
tree | e098cecfe770af08bd77eda320f8a0260c3c68c6 |
first commit
60 files changed, 988 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..d6bed52 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# nvim_config +A usable .config/nvim +# Install +Install vim plug. Look here to find out how https://github.com/junegunn/vim-plug#Installation + +Installl dependencies. The dependencies are powerline, nerdfont, ripgrep, clangd (for c/c++ users), and pylsp (for python users). + +Getting the nvim_config installed. + +cd ~/.config + +git clone https://gitea.com/nathansmithsmith/nvim_config + +mv nvim_config nvim + +nvim ~/.config/nvim/lua/plugin_management.lua + +:PlugInstall + +# Keybindings +leaderkey: ,. + +alt-e to close nvim-cmp popups. + +Open terminal: leader-c + +Toggle/close terminal: A-\ + +Telescope find files: leader-f + +Telescope live grep: leader-g + +Cmake build: leader-b + +Telescope help tags: leader-h + +Telescope marks: leader-m + +Telescope man_pages: leader-p + + +# Moving around. +Hold down alt to move to different windows in split screen. + +To move around in the nvim-cmp popup, telescope, and dashboard use alt-n for next and alt-p for previous and alt-e to close. + diff --git a/assets/rickroll.mp4 b/assets/rickroll.mp4 Binary files differnew file mode 100644 index 0000000..6e3d418 --- /dev/null +++ b/assets/rickroll.mp4 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..950736d --- /dev/null +++ b/init.lua @@ -0,0 +1,22 @@ +require("plugin_management") -- Plugin management should always go first. +require("custom_keybinds") +require("filetype_handing") +require("config_options") + +-- Not a rickroll +-- https://www.youtube.com/watch?v=hvL1339luv0 + +-- Config plugins. +require("rickroll") +require("config_cmp") +require("config_navic") +require("config_toggleterm") +require("config_nvim_tree") +require("config_telescope") +require("config_lualine") +require("config_auto_session") +require("config_cmake") +require("config_custom_dashboard") + +require("cursorline") +require("vim_behavior") diff --git a/lua/config_auto_session.lua b/lua/config_auto_session.lua new file mode 100644 index 0000000..e77584f --- /dev/null +++ b/lua/config_auto_session.lua @@ -0,0 +1,15 @@ +require("auto-session").setup { + log_level = "error", + auto_session_suppress_dirs = { "~/", "~/Documents", "~/Downloads", "~/Desktop", "/"}, + + cwd_change_handling = { + restore_upcoming_session = true, + pre_cwd_changed_hook = nil, + post_cwd_changed_hook = function() + require("lualine").refresh() + end, + }, +} + + +vim.g.session_autoload = "no" diff --git a/lua/config_cmake.lua b/lua/config_cmake.lua new file mode 100644 index 0000000..bed0b89 --- /dev/null +++ b/lua/config_cmake.lua @@ -0,0 +1,19 @@ +local constants = require("constants") + +require("cmake-tools").setup { + cmake_command = "cmake", + cmake_build_directory = "build", + --cmake_build_directory_prefix = "cmake_build_", -- when cmake_build_directory is "", this option will be activated + cmake_generate_options = { "-D", "CMAKE_EXPORT_COMPILE_COMMANDS=1" }, + cmake_build_options = {}, + cmake_console_size = 10, -- cmake output window height + cmake_show_console = "always", -- "always", "only_on_error" + cmake_dap_configuration = { name = "cpp", type = "codelldb", request = "launch" }, -- dap configuration, optional + cmake_dap_open_command = require("dap").repl.open, -- optional + cmake_variants_message = { + short = { show = true }, + long = { show = true, max_length = 40 } + } +} + +vim.keymap.set({"n", "i"}, "<leader>b", ":CMakeBuild<CR>") diff --git a/lua/config_cmp.lua b/lua/config_cmp.lua new file mode 100644 index 0000000..4f0feb8 --- /dev/null +++ b/lua/config_cmp.lua @@ -0,0 +1,188 @@ +vim.opt.completeopt = "menu,menuone,noselect" +local constants = require("constants") + +-- Setup lspconfig. +require'lspconfig'.clangd.setup{} +require'lspconfig'.pylsp.setup{} + +local cmp = require'cmp' + +local kind_icons = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} + +-- The key mapping for the cmd. +local cmd_mapping = { + ['<Tab>'] = { + c = function() + if cmp.visible() then + cmp.select_next_item() + else + feedkeys.call(keymap.t('<C-z>'), 'n') + end + end + }, + + ['<S-Tab>'] = { + c = function() + if cmp.visible() then + cmp.select_prev_item() + else + feedkeys.call(keymap.t('<C-z>'), 'n') + end + end + }, + + [constants.next_key] = { + c = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end + }, + + [constants.previous_key] = { + c = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end + }, + + [constants.close_key] = { + c = cmp.mapping.close(), + } +} + +-- Setup time!!!! +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` usersc; + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = { + [constants.next_key] = cmp.mapping.select_next_item(), + [constants.previous_key] = cmp.mapping.select_prev_item(), + ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. + [constants.close_key] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + ["<CR>"] = cmp.mapping.confirm { select = true }, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + nvim_lua = "[nvim_lua]", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'nvim_lua' }, + { name = 'luasnip' }, -- For luasnip users. + { name = 'path' }, + { name = 'buffer' }, + + }, +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline('/', { + mapping = cmd_mapping, + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmd_mapping, + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + +-- Setup lspconfig. +local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) +local lspconfig = require('lspconfig') + +-- Attaching navic. +local navic = require("nvim-navic") + +local on_attach = function(client, bufnr) + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end +end + +-- C++/C. +lspconfig['clangd'].setup { + capabilities = capabilities, + on_attach = on_attach +} + +-- Python +lspconfig['pylsp'].setup { + capabilities = capabilities, + on_attach = on_attach +} diff --git a/lua/config_custom_dashboard.lua b/lua/config_custom_dashboard.lua new file mode 100644 index 0000000..927b2c5 --- /dev/null +++ b/lua/config_custom_dashboard.lua @@ -0,0 +1,38 @@ +local custom_header = { +[[ ]], +[[ ]], +[[ ▀████▀▄▄ ▄█ ]], +[[ █▀ ▀▀▄▄▄▄▄ ▄▄▀▀█ ]], +[[ ▄ █ ▀▀▀▀▄ ▄▀ ]], +[[ ▄▀ ▀▄ ▀▄ ▀▄▀ ]], +[[ ▄▀ █ █▀ ▄█▀▄ ▄█ ]], +[[ ▀▄ ▀▄ █ ▀██▀ ██▄█ ]], +[[ ▀▄ ▄▀ █ ▄██▄ ▄ ▄ ▀▀ █ ]], +[[ █ ▄▀ █ ▀██▀ ▀▀ ▀▀ ▄▀ ]], +[[ █ █ █ ▄▄ ▄▀ ]], +[[ ]], +} + +local custom_center = { + {icon = "", desc = " Find file", action = "Telescope find_files"}, + {icon = "", desc = " Search Text", action = "Telescope live_grep"}, + {icon = "", desc = " Recent Files", action = "Telescope oldfiles"}, + {icon = "", desc = " Telescope", action = "Telescope"}, + {icon = "", desc = " Terminal", action = "ToggleTerm"}, + {icon = "", desc = " Help", action = "Telescope help_tags"} +} + +require("dashboard").setup { + theme = "doom", + config = { + header = custom_header, + center = custom_center, + footer = {"I spend to much time doing this )-:"}, + }, + + hide = { + statusline = true, + tabline = true, + winbar = true + }, +} diff --git a/lua/config_lualine.lua b/lua/config_lualine.lua new file mode 100644 index 0000000..063c2f9 --- /dev/null +++ b/lua/config_lualine.lua @@ -0,0 +1,83 @@ +local navic = require("nvim-navic") +local tab_component = require("tab_component") + +--local auto_session = require("auto-session-library") +-- +--local get_session_name = function() +-- return string.format(" %s", auto_session.current_session_name()) +--end + +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + "NvimTree", + 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', symbols = {added = '', modified = '', removed = ''}}, + {'diagnostics', symbols = {error = '', warn = '', info = '', hint = 'H'}}, + }, + lualine_c = { + {'filename', symbols = {modified = '', readonly = '', unnamed = '[No Name]', newfile = ''}}, + 'filetype' + }, + lualine_x = {'encoding', 'fileformat'}, + lualine_y = {'progress', 'selectioncount', 'searchcount'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + {'filename', symbols = {modified = '', readonly = '', unnamed = '[No Name]', newfile = ''}}, + 'filetype' + }, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = { + lualine_a = {tab_component.tab_component}, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {{'windows', mode = 2, show_modified_status = false}} + }, + winbar = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {}, + --lualine_c = {{navic.get_location, cond = navic.is_available}}, -- Info from navic and lsp. + lualine_x = {}, + lualine_y = {}, + lualine_z = {} + }, + inactive_winbar = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {}, + --lualine_c = {{navic.get_location, cond = navic.is_available}}, -- Info from navic and lsp. + lualine_x = {}, + lualine_y = {}, + lualine_z = {} + }, + extensions = {} +} diff --git a/lua/config_navic.lua b/lua/config_navic.lua new file mode 100644 index 0000000..c4eec0b --- /dev/null +++ b/lua/config_navic.lua @@ -0,0 +1,35 @@ +require("nvim-navic").setup { + icons = { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = "練", + Interface = "練", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = "◩ ", + Array = " ", + Object = " ", + Key = " ", + Null = "ﳠ ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + highlight = false, + separator = " ", + depth_limit = 0, + depth_limit_indicator = "", + safe_output = true +} diff --git a/lua/config_nvim_tree.lua b/lua/config_nvim_tree.lua new file mode 100644 index 0000000..e36ab13 --- /dev/null +++ b/lua/config_nvim_tree.lua @@ -0,0 +1,24 @@ +-- disable netrw at the very start of your init.lua (strongly advised) +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true + +-- empty setup using defaults +require("nvim-tree").setup() + +-- OR setup with some options +require("nvim-tree").setup({ + sort_by = "case_sensitive", + renderer = { + group_empty = true, + }, + filters = { + dotfiles = false, + }, + on_attach = require("custom_nvim_tree_keybinds").on_attach +}) + +-- Some key binds. +vim.keymap.set("n", "<leader>n", ":NvimTreeToggle<CR>") diff --git a/lua/config_options.lua b/lua/config_options.lua new file mode 100644 index 0000000..78e2b53 --- /dev/null +++ b/lua/config_options.lua @@ -0,0 +1,54 @@ +local autocmd = vim.api.nvim_create_autocmd + +-- vim options. +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.autoindent = true +vim.opt.mouse = 'a' +vim.opt.wrap = true +vim.opt.exrc = true +vim.opt.secure = true +vim.opt.ruler = false +vim.opt.showmode = false +vim.opt.showcmd = true +vim.opt.modeline = false +vim.opt.wildmenu = true +vim.opt.wildmode = "list:full" +vim.opt.smartcase = true +vim.opt.showmode = false +vim.opt.incsearch = true +vim.opt.encoding = "UTF-8" +vim.g.loaded_netrw = 0 +vim.o.shell = "zsh" +vim.o.shortmess = vim.o.shortmess .. "S" +vim.o.showcmd = false + +-- Gui stuff. +vim.opt.guicursor = { + "n-v:blinkon0-block-Cursor/lCursor", + "i-c-ci-ve:hor20-Cursor/lCursor", + "r-cr:hor20", + "o:hor50", + "i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor", + "sm:block-blinkwait175-blinkoff150-blinkon175" +} + +-- Colors. +vim.opt.background = "dark" +vim.cmd("colorscheme gruvbox") + +-- Disable background color in terminal mode. +if vim.fn.has("ttyout") == 1 then + vim.cmd("hi Normal ctermbg=NONE guibg=NONE") +end + +-- True color support. +if os.getenv("COLORTERM") == "truecolor" then + vim.opt.termguicolors = true +end + +-- Copy and pasting. +vim.opt.clipboard = "unnamedplus" + +-- Fonts. +vim.opt.guifont = "Hack Nerd Font:h10" diff --git a/lua/config_telescope.lua b/lua/config_telescope.lua new file mode 100644 index 0000000..d55e30a --- /dev/null +++ b/lua/config_telescope.lua @@ -0,0 +1,24 @@ +local actions = require("telescope.actions") +local constants = require("constants") + +require('telescope').setup{ + defaults = { + mappings = { + i = { + [constants.next_key] = actions.move_selection_next, + [constants.previous_key] = actions.move_selection_previous, + [constants.close_key] = actions.close, + ["<A-x>"] = actions.select_horizontal, + ["<A-v>"] = actions.select_vertical, + ["<A-t>"] = actions.select_tab + } + } + }, +} + +-- Some key binds. +vim.keymap.set({"n", "i"}, "<leader>f", ":Telescope find_files hidden=true<CR>") +vim.keymap.set({"n", "i"}, "<leader>g", ":Telescope live_grep<CR>") +vim.keymap.set({"n", "i"}, "<leader>h", ":Telescope help_tags<CR>") +vim.keymap.set({"n", "i"}, "<leader>m", ":Telescope marks<CR>") +vim.keymap.set({"n", "i"}, "<leader>p", ":Telescope man_pages<CR>") diff --git a/lua/config_toggleterm.lua b/lua/config_toggleterm.lua new file mode 100644 index 0000000..223772d --- /dev/null +++ b/lua/config_toggleterm.lua @@ -0,0 +1,110 @@ +local status_ok, toggleterm = pcall(require, "toggleterm") +if not status_ok then + return +end + +toggleterm.setup { + size = 20, + open_mapping = [[<A-\>]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, + }, +} + +function _G.set_terminal_keymaps() + local opts = { noremap = true } + -- vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts) + -- vim.api.nvim_buf_set_keymap(0, "t", "jk", [[<C-\><C-n>]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<m-h>", [[<C-\><C-n><C-W>h]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<m-j>", [[<C-\><C-n><C-W>j]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<m-k>", [[<C-\><C-n><C-W>k]], opts) + vim.api.nvim_buf_set_keymap(0, "t", "<m-l>", [[<C-\><C-n><C-W>l]], opts) +end + +vim.cmd "autocmd! TermOpen term://* lua set_terminal_keymaps()" + +-- You will never stop me!!! +local rickroll = require("rickroll") +vim.keymap.set({"i", "n", "v"}, "<Right>", rickroll.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Left>", rickroll.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Up>", rickroll.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Down>", rickroll.rickroll) + + +local Terminal = require("toggleterm.terminal").Terminal +local lazygit = Terminal:new { + cmd = "lazygit", + hidden = true, + direction = "float", + float_opts = { + border = "none", + width = 100000, + height = 100000, + }, + on_open = function(_) + vim.cmd "startinsert!" + -- vim.cmd "set laststatus=0" + end, + on_close = function(_) + -- vim.cmd "set laststatus=3" + end, + count = 99, +} + +function _LAZYGIT_TOGGLE() + lazygit:toggle() +end + +local node = Terminal:new { cmd = "node", hidden = true } + +function _NODE_TOGGLE() + node:toggle() +end + +local ncdu = Terminal:new { cmd = "ncdu", hidden = true } + +function _NCDU_TOGGLE() + ncdu:toggle() +end + +local htop = Terminal:new { cmd = "htop", hidden = true } + +function _HTOP_TOGGLE() + htop:toggle() +end + +local python = Terminal:new { cmd = "python", hidden = true } + +function _PYTHON_TOGGLE() + python:toggle() +end + +local cargo_run = Terminal:new { cmd = "cargo run", hidden = true } + +function _CARGO_RUN() + cargo_run:toggle() +end + +local cargo_test = Terminal:new { cmd = "cargo test", hidden = true } + +function _CARGO_TEST() + cargo_test:toggle() +end + +-- Some key binds. +vim.keymap.set({"n", "i"}, "<leader>c", ":ToggleTerm<CR>") diff --git a/lua/constants.lua b/lua/constants.lua new file mode 100644 index 0000000..2ddb894 --- /dev/null +++ b/lua/constants.lua @@ -0,0 +1,7 @@ +local constants = {} + +constants.next_key = "<A-n>" +constants.previous_key = "<A-p>" +constants.close_key = "<A-e>" + +return constants diff --git a/lua/cursorline.lua b/lua/cursorline.lua new file mode 100644 index 0000000..3a486d3 --- /dev/null +++ b/lua/cursorline.lua @@ -0,0 +1,20 @@ +local autocmd = vim.api.nvim_create_autocmd + +local set_cursorline = function() + local buf = vim.api.nvim_get_current_buf() + + -- Do not set cursorline if telescope is open. + if vim.bo[buf].filetype == "TelescopePrompt" then + vim.cmd("set nocul") + else + vim.cmd("set cul") + end +end + +autocmd("InsertEnter", +{pattern="*", callback=set_cursorline +}) + +autocmd("InsertLeave", +{pattern="*", command="set nocul" +}) diff --git a/lua/custom_keybinds.lua b/lua/custom_keybinds.lua new file mode 100644 index 0000000..94ffcac --- /dev/null +++ b/lua/custom_keybinds.lua @@ -0,0 +1,37 @@ +local autocmd = vim.api.nvim_create_autocmd +local constants = require("constants") +local rickroll = require("rickroll") + +-- Leader key. +vim.g['mapleader'] = ",." + +-- Next and previous. +vim.keymap.set({"i", "v", "n", "c"}, constants.next_key, "<C-n>") +vim.keymap.set({"i", "v", "n", "c"}, constants.previous_key, "<C-p>") + +-- Bye bye arrows +vim.keymap.set({"i", "n", "v"}, "<Right>", rickroll.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Left>", rickroll.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Up>", rickroll.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Down>", rickroll.rickroll) + +-- Switching windows. +vim.keymap.set("n", "<A-h>", "<C-w><Left>") +vim.keymap.set("n", "<A-j>", "<C-w><Down>") +vim.keymap.set("n", "<A-k>", "<C-w><Up>") +vim.keymap.set("n", "<A-l>", "<C-w><Right>") + +-- Python scripts. +autocmd("Filetype", +{pattern="python", command="nnoremap <silent> <F5> :!python3 %<CR>" +}) + +-- Shell scripts. +autocmd("Filetype", +{pattern="sh", command="nnoremap <silent> <F5> :!./%<CR>" +}) + +-- Lua scripts. +autocmd("Filetype", +{pattern="lua", command="nnoremap <silent> <F5> :!lua %<CR>" +}) diff --git a/lua/custom_nvim_tree_keybinds.lua b/lua/custom_nvim_tree_keybinds.lua new file mode 100644 index 0000000..fcd3781 --- /dev/null +++ b/lua/custom_nvim_tree_keybinds.lua @@ -0,0 +1,98 @@ +local M = {} + +function M.on_attach(bufnr) + local api = require('nvim-tree.api') + + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + + vim.keymap.set('n', '<C-]>', api.tree.change_root_to_node, opts('CD')) + vim.keymap.set('n', '<C-e>', api.node.open.replace_tree_buffer, opts('Open: In Place')) + vim.keymap.set('n', '<C-k>', api.node.show_info_popup, opts('Info')) + vim.keymap.set('n', '<C-r>', api.fs.rename_sub, opts('Rename: Omit Filename')) + vim.keymap.set('n', 't', api.node.open.tab, opts('Open: New Tab')) + vim.keymap.set('n', '<C-v>', api.node.open.vertical, opts('Open: Vertical Split')) + vim.keymap.set('n', '<C-x>', api.node.open.horizontal, opts('Open: Horizontal Split')) + vim.keymap.set('n', '<BS>', api.node.navigate.parent_close, opts('Close Directory')) + vim.keymap.set('n', '<CR>', api.node.open.edit, opts('Open')) + vim.keymap.set('n', '<Tab>', api.node.open.preview, opts('Open Preview')) + vim.keymap.set('n', '>', api.node.navigate.sibling.next, opts('Next Sibling')) + vim.keymap.set('n', '<', api.node.navigate.sibling.prev, opts('Previous Sibling')) + vim.keymap.set('n', '.', api.node.run.cmd, opts('Run Command')) + vim.keymap.set('n', '-', api.tree.change_root_to_parent, opts('Up')) + vim.keymap.set('n', 'a', api.fs.create, opts('Create')) + vim.keymap.set('n', 'bmv', api.marks.bulk.move, opts('Move Bookmarked')) + vim.keymap.set('n', 'B', api.tree.toggle_no_buffer_filter, opts('Toggle No Buffer')) + vim.keymap.set('n', 'c', api.fs.copy.node, opts('Copy')) + vim.keymap.set('n', 'C', api.tree.toggle_git_clean_filter, opts('Toggle Git Clean')) + vim.keymap.set('n', '[c', api.node.navigate.git.prev, opts('Prev Git')) + vim.keymap.set('n', ']c', api.node.navigate.git.next, opts('Next Git')) + vim.keymap.set('n', 'd', api.fs.remove, opts('Delete')) + vim.keymap.set('n', 'D', api.fs.trash, opts('Trash')) + vim.keymap.set('n', 'E', api.tree.expand_all, opts('Expand All')) + vim.keymap.set('n', 'e', api.fs.rename_basename, opts('Rename: Basename')) + vim.keymap.set('n', ']e', api.node.navigate.diagnostics.next, opts('Next Diagnostic')) + vim.keymap.set('n', '[e', api.node.navigate.diagnostics.prev, opts('Prev Diagnostic')) + vim.keymap.set('n', 'F', api.live_filter.clear, opts('Clean Filter')) + vim.keymap.set('n', 'f', api.live_filter.start, opts('Filter')) + vim.keymap.set('n', 'g?', api.tree.toggle_help, opts('Help')) + vim.keymap.set('n', 'gy', api.fs.copy.absolute_path, opts('Copy Absolute Path')) + vim.keymap.set('n', 'H', api.tree.toggle_hidden_filter, opts('Toggle Dotfiles')) + vim.keymap.set('n', 'I', api.tree.toggle_gitignore_filter, opts('Toggle Git Ignore')) + vim.keymap.set('n', 'J', api.node.navigate.sibling.last, opts('Last Sibling')) + vim.keymap.set('n', 'K', api.node.navigate.sibling.first, opts('First Sibling')) + vim.keymap.set('n', 'm', api.marks.toggle, opts('Toggle Bookmark')) + vim.keymap.set('n', 'o', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'O', api.node.open.no_window_picker, opts('Open: No Window Picker')) + vim.keymap.set('n', 'p', api.fs.paste, opts('Paste')) + vim.keymap.set('n', 'P', api.node.navigate.parent, opts('Parent Directory')) + vim.keymap.set('n', 'q', api.tree.close, opts('Close')) + vim.keymap.set('n', 'r', api.fs.rename, opts('Rename')) + vim.keymap.set('n', 'R', api.tree.reload, opts('Refresh')) + vim.keymap.set('n', 's', api.node.run.system, opts('Run System')) + vim.keymap.set('n', 'S', api.tree.search_node, opts('Search')) + vim.keymap.set('n', 'U', api.tree.toggle_custom_filter, opts('Toggle Hidden')) + vim.keymap.set('n', 'W', api.tree.collapse_all, opts('Collapse')) + vim.keymap.set('n', 'x', api.fs.cut, opts('Cut')) + vim.keymap.set('n', 'y', api.fs.copy.filename, opts('Copy Name')) + vim.keymap.set('n', 'Y', api.fs.copy.relative_path, opts('Copy Relative Path')) + vim.keymap.set('n', '<2-LeftMouse>', api.node.open.edit, opts('Open')) + vim.keymap.set('n', '<2-RightMouse>', api.tree.change_root_to_node, opts('CD')) + + + -- Mappings removed via: + -- remove_keymaps + -- OR + -- view.mappings.list..action = "" + -- + -- The dummy set before del is done for safety, in case a default mapping does not exist. + -- + -- You might tidy things by removing these along with their default mapping. + vim.keymap.set('n', 'O', '', { buffer = bufnr }) + vim.keymap.del('n', 'O', { buffer = bufnr }) + vim.keymap.set('n', '<2-RightMouse>', '', { buffer = bufnr }) + vim.keymap.del('n', '<2-RightMouse>', { buffer = bufnr }) + vim.keymap.set('n', 'D', '', { buffer = bufnr }) + vim.keymap.del('n', 'D', { buffer = bufnr }) + vim.keymap.set('n', 'E', '', { buffer = bufnr }) + vim.keymap.del('n', 'E', { buffer = bufnr }) + + + -- Mappings migrated from view.mappings.list + -- + -- You will need to insert "your code goes here" for any mappings with a custom action_cb + vim.keymap.set('n', 'A', api.tree.expand_all, opts('Expand All')) + vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help')) + vim.keymap.set('n', 'C', api.tree.change_root_to_node, opts('CD')) + vim.keymap.set('n', 'P', function() + local node = api.tree.get_node_under_cursor() + print(node.absolute_path) + end, opts('Print Node Path')) + + vim.keymap.set('n', 'Z', api.node.run.system, opts('Run System')) + +end + +return M diff --git a/lua/filetype_handing.lua b/lua/filetype_handing.lua new file mode 100644 index 0000000..3cf00ca --- /dev/null +++ b/lua/filetype_handing.lua @@ -0,0 +1,57 @@ +local autocmd = vim.api.nvim_create_autocmd + +-- Filetypes. +vim.cmd("filetype on") +vim.cmd("filetype plugin on") +vim.cmd("filetype indent on") + +-- Python. +autocmd("Filetype", +{pattern="python", command="set nocindent tabstop=4 shiftwidth=4 expandtab softtabstop=4" +}) + +-- Text files. +autocmd("Filetype", +{pattern="*.txt", command="set formatoptions+=t textwidth=72 nocindent noexpandtab shiftwidth=8 tabstop=8 softtabstop=8" +}) + +-- C and c++. +autocmd("Filetype", +{pattern={"c", "cpp", "slang"}, +command="set cindent tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab" +}) + +-- Only c. +autocmd("Filetype", +{pattern="c", command="set formatoptions+=ro" +}) + +-- Assembly. +autocmd("Filetype", +{pattern="asm", command="set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab" +}) + +-- Lua. +autocmd("Filetype", +{pattern="lua", command="set cindent tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab" +}) + +-- css. +autocmd("Filetype", +{pattern="css", command="set smartindent" +}) + +-- html. +autocmd("Filetype", +{pattern="html", command="set formatoptions+=tl" +}) + +-- html and css. +autocmd("Filetype", +{pattern={"html", "css"}, command="set noexpandtab tabstop=2" +}) + +-- Make files. +autocmd("Filetype", +{pattern="make", command="set nocindent noexpandtab shiftwidth=8 tabstop=8 softtabstop=8" +}) diff --git a/lua/plugin_management.lua b/lua/plugin_management.lua new file mode 100644 index 0000000..326f35c --- /dev/null +++ b/lua/plugin_management.lua @@ -0,0 +1,59 @@ +local Plug = vim.fn['plug#'] + +vim.call('plug#begin', '~/.config/nvim/plugged') + +-- nvim-cmp. +Plug "neovim/nvim-lspconfig" +Plug "hrsh7th/nvim-cmp" +Plug "hrsh7th/cmp-buffer" +Plug "hrsh7th/cmp-path" +Plug "saadparwaiz1/cmp_luasnip" +Plug "hrsh7th/cmp-nvim-lsp" +Plug "hrsh7th/cmp-nvim-lua" +Plug "L3MON4D3/LuaSnip" +Plug "rafamadriz/friendly-snippets" +Plug "neovim/nvim-lspconfig" +Plug "williamboman/nvim-lsp-installer" +Plug "jose-elias-alvarez/null-ls.nvim" +Plug "hrsh7th/cmp-cmdline" + +-- Themes. +Plug "morhetz/gruvbox" +Plug "ayu-theme/ayu-vim" +Plug "davidosomething/vim-colors-meh" +Plug "sainnhe/gruvbox-material" +Plug "arcticicestudio/nord-vim" +Plug "haishanh/night-owl.vim" +Plug "nanotech/jellybeans.vim" +Plug "sjl/badwolf" +Plug "tpope/vim-vividchalk" +Plug "tomasr/molokai" +Plug "dracula/vim" + +-- Fonts. +Plug "powerline/fonts" + +-- Gui. +Plug "nvim-tree/nvim-web-devicons" +Plug "nvim-tree/nvim-tree.lua" +Plug "nvim-lualine/lualine.nvim" +Plug "akinsho/toggleterm.nvim" +Plug "glepnir/dashboard-nvim" +Plug "smiteshp/nvim-navic" + +-- Telescope. +Plug "BurntSushi/ripgrep" +Plug "nvim-lua/plenary.nvim" +Plug "nvim-telescope/telescope.nvim" + +-- Cmake. +Plug "mfussenegger/nvim-dap" +Plug "Civitasv/cmake-tools.nvim" + +-- Session +Plug "rmagatti/auto-session" + +-- Highlighting. +Plug "sheerun/vim-polyglot" + +vim.call('plug#end') diff --git a/lua/rickroll.lua b/lua/rickroll.lua new file mode 100644 index 0000000..71465d4 --- /dev/null +++ b/lua/rickroll.lua @@ -0,0 +1,16 @@ +M = {} + +function M.rickroll() + local handle = io.popen('xdg-open ~/.config/nvim/assets/rickroll.mp4 > /dev/null 2> /dev/null') + handle:close() +end + +vim.api.nvim_create_user_command("Rickroll", M.rickroll, {}) + +-- Hehehehehehe. If you are reading this griffin JUST USE HJKL!!! +vim.keymap.set({"i", "n", "v"}, "<Right>", M.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Left>", M.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Up>", M.rickroll) +vim.keymap.set({"i", "n", "v"}, "<Down>", M.rickroll) + +return M diff --git a/lua/tab_component.lua b/lua/tab_component.lua new file mode 100644 index 0000000..44fae45 --- /dev/null +++ b/lua/tab_component.lua @@ -0,0 +1,27 @@ +local M = {} + +local fmt = function(name, context) + local buflist = vim.fn.tabpagebuflist(context.tabnr) + local current_tab = vim.api.nvim_get_current_tabpage() + local winnr = vim.fn.tabpagewinnr(context.tabnr) + local bufnr = buflist[winnr] + local mod = vim.fn.getbufvar(bufnr, '&mod') + local icon = require('nvim-web-devicons').get_icon(name) + + if icon == nil then + icon = '' + else + icon = icon .. ' ' + end + + return icon .. name .. " " .. context.tabnr +end + +M.tab_component = { + "tabs", + max_length = vim.o.columns, + mode = 1, + fmt = fmt +} + +return M diff --git a/lua/vim_behavior.lua b/lua/vim_behavior.lua new file mode 100644 index 0000000..026c5c2 --- /dev/null +++ b/lua/vim_behavior.lua @@ -0,0 +1,6 @@ +local autocmd = vim.api.nvim_create_autocmd + +-- Restore cursor position. +autocmd("BufReadPost", +{pattern="*" , command="silent! normal! g`\"zv" +}) diff --git a/open_config.vim b/open_config.vim new file mode 100644 index 0000000..3b8176d --- /dev/null +++ b/open_config.vim @@ -0,0 +1,3 @@ +cd ~/.config/nvim +e init.lua +NvimTreeOpen diff --git a/plugged/LuaSnip b/plugged/LuaSnip new file mode 160000 +Subproject b4bc24c4925aeb05fd47d2ee9b24b7f73f5d7e3 diff --git a/plugged/auto-session b/plugged/auto-session new file mode 160000 +Subproject 220693e1583152c71d41735a6a924b52cefcfe0 diff --git a/plugged/ayu-vim b/plugged/ayu-vim new file mode 160000 +Subproject 0745635421688ce777f663d13531996cb4da651 diff --git a/plugged/badwolf b/plugged/badwolf new file mode 160000 +Subproject 682b5215be013237f39be14954e6979426724a3 diff --git a/plugged/cmake-tools.nvim b/plugged/cmake-tools.nvim new file mode 160000 +Subproject b279bfb861666563399de3599c24040b53a42fd diff --git a/plugged/cmp-buffer b/plugged/cmp-buffer new file mode 160000 +Subproject 3022dbc9166796b644a841a02de8dd1cc1d311f diff --git a/plugged/cmp-cmdline b/plugged/cmp-cmdline new file mode 160000 +Subproject 5af1bb7d722ef8a96658f01d6eb219c4cf746b3 diff --git a/plugged/cmp-nvim-lsp b/plugged/cmp-nvim-lsp new file mode 160000 +Subproject 0e6b2ed705ddcff9738ec4ea838141654f12eee diff --git a/plugged/cmp-nvim-lua b/plugged/cmp-nvim-lua new file mode 160000 +Subproject f12408bdb54c39c23e67cab726264c10db33ada diff --git a/plugged/cmp-path b/plugged/cmp-path new file mode 160000 +Subproject 91ff86cd9c29299a64f968ebb45846c485725f2 diff --git a/plugged/cmp_luasnip b/plugged/cmp_luasnip new file mode 160000 +Subproject 18095520391186d634a0045dacaa34629109656 diff --git a/plugged/dashboard-nvim b/plugged/dashboard-nvim new file mode 160000 +Subproject 0af0ad181db271ef8d5a332f4cfcec911834049 diff --git a/plugged/fonts b/plugged/fonts new file mode 160000 +Subproject e80e3eba9091dac0655a0a77472e10f53e754bb diff --git a/plugged/friendly-snippets b/plugged/friendly-snippets new file mode 160000 +Subproject 1d0dac346de7c6895ac72528df3276386c6b149 diff --git a/plugged/gruvbox b/plugged/gruvbox new file mode 160000 +Subproject bf2885a95efdad7bd5e4794dd0213917770d79b diff --git a/plugged/gruvbox-material b/plugged/gruvbox-material new file mode 160000 +Subproject 3fff63b0d6a425ad1076a260cd4f6da61d1632b diff --git a/plugged/jellybeans.vim b/plugged/jellybeans.vim new file mode 160000 +Subproject ef83bf4dc8b3eacffc97bf5c96ab2581b415c9f diff --git a/plugged/lualine.nvim b/plugged/lualine.nvim new file mode 160000 +Subproject 05d78e9fd0cdfb4545974a5aa14b1be95a86e9c diff --git a/plugged/molokai b/plugged/molokai new file mode 160000 +Subproject c67bdfcdb31415aa0ade7f8c003261700a88547 diff --git a/plugged/night-owl.vim b/plugged/night-owl.vim new file mode 160000 +Subproject 783a41a27f7fe55ed91d1ec0f0351d06ae17fbc diff --git a/plugged/nord-vim b/plugged/nord-vim new file mode 160000 +Subproject f13f5dfbb784deddbc1d8195f34dfd9ec73e229 diff --git a/plugged/null-ls.nvim b/plugged/null-ls.nvim new file mode 160000 +Subproject 08bb00c7c2cd58c72e02cf54e4b9cbfe14b03e0 diff --git a/plugged/nvim-cmp b/plugged/nvim-cmp new file mode 160000 +Subproject d153771162bd9795d9f7142df5c674b61066a58 diff --git a/plugged/nvim-dap b/plugged/nvim-dap new file mode 160000 +Subproject 6cedcb527e264c8f25e86afa8dae74c6692dee5 diff --git a/plugged/nvim-lsp-installer b/plugged/nvim-lsp-installer new file mode 160000 +Subproject 17e0bfa5f2c8854d1636fcd036dc8284db136ba diff --git a/plugged/nvim-lspconfig b/plugged/nvim-lspconfig new file mode 160000 +Subproject df58d91c9351a9dc5be6cf8d54f49ab0d9a64e7 diff --git a/plugged/nvim-navic b/plugged/nvim-navic new file mode 160000 +Subproject 15704c607569d6c5cfeab486d3ef9459645a70c diff --git a/plugged/nvim-tree.lua b/plugged/nvim-tree.lua new file mode 160000 +Subproject 89816ace70642e9d3db0dab3dc68918f8979ec3 diff --git a/plugged/nvim-web-devicons b/plugged/nvim-web-devicons new file mode 160000 +Subproject 986875b7364095d6535e28bd4aac3a9357e91bb diff --git a/plugged/plenary.nvim b/plugged/plenary.nvim new file mode 160000 +Subproject 9ac3e9541bbabd9d73663d757e4fe48a675bb05 diff --git a/plugged/ripgrep b/plugged/ripgrep new file mode 160000 +Subproject 041544853c86dde91c49983e5ddd0aa799bd283 diff --git a/plugged/telescope.nvim b/plugged/telescope.nvim new file mode 160000 +Subproject b8918d1261c6889c62388783f90fda16830d89f diff --git a/plugged/toggleterm.nvim b/plugged/toggleterm.nvim new file mode 160000 +Subproject 68fdf851c2b7901a7065ff129b77d3483419ddc diff --git a/plugged/vim b/plugged/vim new file mode 160000 +Subproject eb577d47b0cfc9191bf04c414b4042d5f1a980f diff --git a/plugged/vim-colors-meh b/plugged/vim-colors-meh new file mode 160000 +Subproject 435400a4285be463e733e1a70b0c1bd996f8186 diff --git a/plugged/vim-polyglot b/plugged/vim-polyglot new file mode 160000 +Subproject bc8a81d3592dab86334f27d1d43c080ebf680d4 diff --git a/plugged/vim-vividchalk b/plugged/vim-vividchalk new file mode 160000 +Subproject be5c6251279bfcfa55cdea8c9a8ccd7a56c8a64 |