~poldi1405/dotfiles

62359fd5f3372bd3da9542601ebd4f53758007db — Moritz Poldrack 8 months ago ec9e49f master
nvim: add new config
A config/nvim/init.lua => config/nvim/init.lua +94 -0
@@ 0,0 1,94 @@
-- highlight column 80
vim.wo.colorcolumn = '80'

-- make space the leader key
vim.g.mapleader = ' '

-- tab bindings are atrocious
vim.api.nvim_set_keymap("n", "tr", ":bp<CR>", {})
vim.api.nvim_set_keymap("n", "tz", ":bn<CR>", {})
vim.api.nvim_set_keymap("n", "tc", ":bd<CR>", {})
vim.api.nvim_set_keymap("n", "-", ":Explore<CR>", {})

-- disable those useless shits
vim.api.nvim_set_keymap("n", "<PageUp>", "<nop>", {})
vim.api.nvim_set_keymap("n", "<PageDown>", "<nop>", {})

-- clear highlights on enter and escape
vim.opt.incsearch = true
vim.opt.hlsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.api.nvim_set_keymap("n", "<Esc>", ":noh<CR>", {silent = true})
vim.api.nvim_set_keymap("n", "<CR>", ":noh<CR>", {silent = true})

-- open file browser on -
vim.api.nvim_set_keymap("n", "-", ":Explore<CR>", {silent = true})

-- completion-menu
vim.opt.wildmode = "longest,list,full"
vim.opt.completeopt = "longest,menuone"

-- auto-load changes
vim.opt.autoread = true

-- always show 2 lines around the cursor
vim.opt.scrolloff = 2

-- don't expand cache or temporary paths
vim.opt.wildignore = {'*/cache/*', '*/tmp/*'}

-- show line numbers
vim.opt.number = true

-- syntax highlighting… we aren't savages
vim.opt.syntax = "enable"

-- make :find actually find things
vim.opt.path = vim.opt.path + ",**"

-- disable mouse
vim.opt.mouse = ""

-- sane indentation settings
vim.opt.autoindent = true
vim.opt.shiftwidth = 8
vim.opt.softtabstop = 8
vim.opt.tabstop = 8
vim.opt.expandtab = false

-- faster updates
vim.opt.updatetime=100

-- wrapping at whitespace
vim.opt.lbr = true
vim.opt.breakindent = true
vim.opt.formatoptions = "tcrqn1j"

-- unmap space and reassign as <leader>
vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent = true })
vim.g.mapleader = " "
vim.g.maplocalleader = " "

-- map quickfix stuff to <leader>c
vim.api.nvim_set_keymap('n', '<leader>cc', ':cw<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>cg', ':.cc<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>cn', ':cn<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>cp', ':cp<cr>', { noremap = true, silent = true })

-- move around splits with shift-arrows
vim.api.nvim_set_keymap('n', '<s-up>', ':wincmd k<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<s-down>', ':wincmd j<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<s-left>', ':wincmd h<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<s-right>', ':wincmd l<cr>', { noremap = true, silent = true })

-- restore cursor position
local function restore_cursor()
	if vim.fn.line("'\"") > 1 and vim.fn.line("'\"") <= vim.fn.line("$") then
		vim.cmd("normal! g'\"")
	end
end
vim.api.nvim_create_autocmd({"BufReadPost"}, { callback = restore_cursor })

package.path = package.path..";"..os.getenv("HOME").."/.config/nvim/lua/?.lua"
require('plugins')

A config/nvim/lua/plugin_ale.lua => config/nvim/lua/plugin_ale.lua +8 -0
@@ 0,0 1,8 @@
vim.g.ale_fix_on_save = 1
vim.g.ale_lint_on_text_changed = 1
vim.g.ale_fixers = {
	["*"] = { 'remove_trailing_lines', 'trim_whitespace' }
}
vim.g.ale_linters = {
	go = { 'revive', 'staticcheck' }
}

A config/nvim/lua/plugin_completion.lua => config/nvim/lua/plugin_completion.lua +40 -0
@@ 0,0 1,40 @@
local lsp = require('lsp-zero').preset({})

lsp.on_attach(function(client, bufnr)
	lsp.default_keymaps({buffer = bufnr})
end)

local lspc = require('lspconfig')
lspc.clangd.setup{}
lspc.gopls.setup{}
lspc.bashls.setup{}
lspc.ltex.setup{}

lsp.setup()

local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")

cmp.setup({
	mapping = {
		['<Tab>'] = cmp_action.tab_complete(),
		['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
		['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
		['<Tab>'] = cmp.mapping(
		function(fallback)
			cmp_ultisnips_mappings.compose {'select_next_item', 'jump_forwards'}(fallback)
		end, {'i', 's'}
		),
	},
	sources = {
		{ name = 'nvim_lsp' },
		{ name = 'ultisnips' },
		{ name = 'path' },
	},
	snippet = {
		expand = function(args)
			vim.fn["UltiSnips#Anon"](args.body)
		end
	},
})

A config/nvim/lua/plugin_harpoon.lua => config/nvim/lua/plugin_harpoon.lua +17 -0
@@ 0,0 1,17 @@
vim.api.nvim_set_keymap('n','<leader>p', ':lua require("harpoon.mark").add_file()<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n','<leader>d', ':lua require("harpoon.mark").rm_file()<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n','<leader>tr', ':lua require("harpoon.ui").nav_prev()<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n','<leader>tz', ':lua require("harpoon.ui").nav_next()<cr>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n','<leader><leader>', ':lua require("harpoon.ui").toggle_quick_menu()<cr>', { noremap = true, silent = true })

require("harpoon").setup({ 
    -- sets the marks upon calling `toggle` on the ui, instead of require `:w`.
    save_on_toggle = true,

    -- filetypes that you want to prevent from adding to the harpoon list menu.
    excluded_filetypes = { "harpoon" },

    -- set marks specific to each git branch inside git repository
    mark_branch = true,
})


A config/nvim/lua/plugin_markdown.lua => config/nvim/lua/plugin_markdown.lua +2 -0
@@ 0,0 1,2 @@
vim.g.markdown_mapping_switch_status = '<Leader>tt'
vim.g.vim_markdown_math = 1

A config/nvim/lua/plugin_theme.lua => config/nvim/lua/plugin_theme.lua +19 -0
@@ 0,0 1,19 @@
-- theme in general
local c = require('vscode.colors').get_colors()
require('vscode').setup({
	transparent = true,
	italic_comments = true,
	color_overrides = {
		vscLineNumber = '#FFFFFF',
	},
})
require('vscode').load()

-- buffer line
require('bufferline').setup {
	options = {
		modified_icon = '',
		show_buffer_icons = false,
		show_buffer_close_icon = false,
	}
}

A config/nvim/lua/plugin_vimgo.lua => config/nvim/lua/plugin_vimgo.lua +8 -0
@@ 0,0 1,8 @@
vim.g['go_fmt_command'] = "gopls"
vim.g['go_gopls_gofumpt'] = 1
vim.g['go_auto_type_info'] = 1

-- Custom keybindings from hell
vim.keymap.set('n', 'gie', '<Cmd>GoIfErr<CR>' )
vim.keymap.set('n', 'gis', '<Cmd>GoFillStruct<CR>' )


A config/nvim/lua/plugins.lua => config/nvim/lua/plugins.lua +109 -0
@@ 0,0 1,109 @@
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
	packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
	-- fn.system({'yay', '-Syu', 'go', 'shellcheck', 'python', '--noconfirm'})
	vim.cmd("terminal yay -Syu go shellcheck python python-pynvim clang gopls bash-language-server ltex-ls-bin --noconfirm")
end

vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])

return require('packer').startup({function(use)
	-- packer managed packer
	use 'wbthomason/packer.nvim'

	-- nice file menu
	use { 'ThePrimeagen/harpoon', requires = { { 'nvim-lua/plenary.nvim' }} }

	-- Go-editing
	use {
		'fatih/vim-go',
		ft = {'go'},
		run = function() vim.cmd([[GoUpdateBinaries]]) end
	}

	-- extra file formats
	use { 'codelitt/vim-qtpl', ft = {'qtpl'} }

	-- snippets and completion
	use {
		'VonHeikemen/lsp-zero.nvim',
		requires = {
			-- LSP Support
			{'neovim/nvim-lspconfig'},

			-- Autocompletion
			{'hrsh7th/nvim-cmp'},
			{'hrsh7th/cmp-nvim-lsp'},
			{'hrsh7th/cmp-path'},
			{'quangnguyen30192/cmp-nvim-ultisnips', requires = { 'SirVer/ultisnips' }},
		}
	}

	-- autolint all the things
	use { 'dense-analysis/ale' }

	-- better markdown editing
	use {
		'gabrielelana/vim-markdown',
		ft = {'markdown'},
		requires = { 'godlygeek/tabular' },
	}

	------------------------------------
	--        the small things        --
	------------------------------------

	-- sudo for writing and editing if needed
	use { 'lambdalisue/suda.vim' }

	-- align stuff
	use { 'tommcdo/vim-lion' }

	-- comment stuff out
	use { 'tpope/vim-commentary' }

	------------------------------------
	--          "AESTHETICS"          --
	------------------------------------

	-- show git diffs in the gutter
	use { 'mhinz/vim-signify' }

	-- say what you want, but that colorscheme is quite alright
	use { 'Mofiqul/vscode.nvim' }

	-- show me my open buffers
	use {
		'akinsho/bufferline.nvim',
		requires = 'nvim-tree/nvim-web-devicons'
	}

	if packer_bootstrap then
		require('packer').sync()
		vim.fn.PackerInstall()
	end

	-- load plugin-specific settings
	files = io.popen('find "$HOME"/.config/nvim/lua/ -name plugin_*.lua')
	for file in files:lines() do
		local req_file = file:gmatch('%/lua%/(.+).lua$'){0}:gsub('/', '.')
		status_ok, _ = pcall(require, req_file)

		if not status_ok then
			vim.notify('Failed loading ' .. req_file, vim.log.levels.ERROR)
		end
	end
end,
config = {
	display = {
		open_fn = function()
			return require('packer.util').float({ border = 'single' })
		end
	}
}})