diff options
Diffstat (limited to 'nvim/lua')
| -rw-r--r-- | nvim/lua/config/keymaps.lua | 31 | ||||
| -rw-r--r-- | nvim/lua/config/lazy.lua | 26 | ||||
| -rw-r--r-- | nvim/lua/config/options.lua | 117 | ||||
| -rw-r--r-- | nvim/lua/plugins/ale.lua | 17 | ||||
| -rw-r--r-- | nvim/lua/plugins/init.lua | 82 | ||||
| -rw-r--r-- | nvim/lua/plugins/nvim-cmp.lua | 40 | ||||
| -rw-r--r-- | nvim/lua/plugins/nvim-lspconfig.lua | 18 | ||||
| -rw-r--r-- | nvim/lua/plugins/nvim-tree.lua | 47 | ||||
| -rw-r--r-- | nvim/lua/plugins/nvim-treesitter.lua | 14 | ||||
| -rw-r--r-- | nvim/lua/plugins/outline.lua | 23 | ||||
| -rw-r--r-- | nvim/lua/plugins/telescope.lua | 31 | ||||
| -rw-r--r-- | nvim/lua/plugins/undotree.lua | 9 | ||||
| -rw-r--r-- | nvim/lua/plugins/which-key.lua | 18 |
13 files changed, 473 insertions, 0 deletions
diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..073233f --- /dev/null +++ b/nvim/lua/config/keymaps.lua @@ -0,0 +1,31 @@ + +-- -- use system clipboard +-- vim.o.clipboard = '' +-- vim.keymap.set('n', '""y', '""y') +-- vim.keymap.set('n', '""yy', '""yy') +-- vim.keymap.set('n', '""p', '""p') +-- vim.keymap.set('n', '""P', '""P') +-- vim.keymap.set('n', 'y', function() return (vim.v.register == '"' and '"+' or '') .. 'y' end, { expr = true }) +-- vim.keymap.set('n', 'yy', function() return (vim.v.register == '"' and '"+' or '') .. 'yy' end, { expr = true }) +-- vim.keymap.set('n', 'p', function() return (vim.v.register == '"' and '"+' or '') .. 'p' end, { expr = true }) +-- vim.keymap.set('n', 'P', function() return (vim.v.register == '"' and '"+' or '') .. 'P' end, { expr = true }) +-- +-- -- copy/paste +-- vim.keymap.set('n', '<C-x>', '"+dd') +-- vim.keymap.set('v', '<C-x>', '"+d') +-- vim.keymap.set('n', '<C-c>', '"+yy') +-- vim.keymap.set('v', '<C-c>', '"+y') +-- vim.keymap.set({'n', 'v'}, '<C-v>', '"+p') +-- vim.keymap.set('i', '<C-v>', '<C-r>+') + +-- trim whitespace +vim.keymap.set('n', '<leader>wt', [[:%s/\s\+$//e<cr>]], {desc = 'Trim whitespace'}) + + + +-- toggle virtual text +vim.keymap.set('n', '<leader>tv', function() + vim.diagnostic.config {virtual_text = not vim.diagnostic.config().virtual_text} +end, {desc = 'Toggle diagnostics virtual text'}) + + diff --git a/nvim/lua/config/lazy.lua b/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..d604abf --- /dev/null +++ b/nvim/lua/config/lazy.lua @@ -0,0 +1,26 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ + "git", "clone", "--filter=blob:none", "--branch=stable", + lazyrepo, + lazypath + }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + {"Failed to clone lazy.nvim:\n", "ErrorMsg"}, + {out, "WarningMsg"}, + {"\nPress any key to exit..."}, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup { + spec = { + {import = 'plugins'} + }, + lockfile = vim.fn.stdpath("data") .. "/lazy/lock.json" +} diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua new file mode 100644 index 0000000..48fcd65 --- /dev/null +++ b/nvim/lua/config/options.lua @@ -0,0 +1,117 @@ +-- use modern vim +vim.o.compatible = false + +-- dont use backup files +vim.o.backup = false +vim.o.writebackup = false +vim.o.swapfile = false + +-- allow unsaved buffers +vim.o.hidden = true + +-- enable mouse +vim.o.mouse = 'a' + +-- display tabs and trailing spaces +vim.o.list = true +vim.o.listchars = 'tab:»·,trail:·,nbsp:·' + +-- search options +vim.o.incsearch = true +vim.o.hlsearch = true + +-- backspace in insert mode +vim.o.backspace = "indent,eol,start" + +-- no sound +vim.o.visualbell = true + +-- set autoread +vim.o.autoread = true + +-- set encoding +vim.o.encoding = "utf-8" +vim.o.fileencoding = "utf-8" + +-- show commands +vim.o.showcmd = true + +-- file format +vim.o.fileformats = "unix,dos" + +-- set leader +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- set system clipboard +vim.o.clipboard = 'unnamedplus' + +-- disable conceal +vim.g.vim_json_conceal = 0 +vim.g.markdown_syntax_conceal = 0 +vim.o.conceallevel = 0 +vim.api.nvim_create_autocmd({"FileType"}, { + pattern = "json", + command = "set conceallevel=0" +}) + +-- show line numbers +vim.o.number = true + +-- 80 character line length highlight +vim.o.colorcolumn = "80" + +-- highlight current line +vim.o.cursorline = true + +-- set tab width and use spaces for tabs +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.softtabstop = 4 +vim.o.expandtab = true + +-- disable netrw +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- set colours +vim.opt.termguicolors = true + +-- make files use regular tabs +vim.api.nvim_create_autocmd({"FileType"}, { + pattern = "make", + command = "set tabstop=4 shiftwidth=8 softtabstop=0 noexpandtab" +}) + +-- reload vimrc on change +vim.api.nvim_create_augroup("reload_vimrc", {}) +vim.api.nvim_create_autocmd({"BufWritePost"}, { + group = "reload_vimrc", + pattern = vim.env.MYVIMRC, + callback = function() + vim.cmd "source $MYVIMRC" + -- require('packer').sync() + -- require('packer').compile() + end +}) + +-- gui settings +vim.o.linespace = 4 +-- vim.o.guifont = "monospace:h12" + +-- neovide settings +if vim.g.neovide then + vim.g.neovide_cursor_animation_length = 0.01 + vim.g.neovide_cursor_trail_length = 0.01 + vim.g.neovide_cursor_vfx_mode = "" + vim.g.neovide_remember_window_size = true + vim.g.neovide_scale_factor = 1.0 + + vim.keymap.set('n', '<C-=>', function() + vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1 + end) + + vim.keymap.set('n', '<C-->', function() + vim.g.neovide_scale_factor = vim.g.neovide_scale_factor / 1.1 + end) +end diff --git a/nvim/lua/plugins/ale.lua b/nvim/lua/plugins/ale.lua new file mode 100644 index 0000000..6219a20 --- /dev/null +++ b/nvim/lua/plugins/ale.lua @@ -0,0 +1,17 @@ +do return {} end +return { + { + 'dense-analysis/ale', + config = function() + vim.g.ale_linters_explicit = 1 + -- vim.g.ale_virtualtext_cursor = 'current' + vim.g.ale_virtualtext_cursor = 'disabled' + vim.g.ale_linters = { + python = {'flake8'}, + lua = {'lua_language_server'}, + c = {'clangd'} + } + + end + } +} diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..7ad84ab --- /dev/null +++ b/nvim/lua/plugins/init.lua @@ -0,0 +1,82 @@ +return { + { + 'tanvirtin/monokai.nvim', + priority = 100, + opts = {} + }, + + {'christoomey/vim-tmux-navigator'}, + + {'mg979/vim-visual-multi'}, + + { + 'akinsho/bufferline.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + opts = {} + }, + + { + 'nvim-lualine/lualine.nvim', + dependencies = { + 'tanvirtin/monokai.nvim' + }, + opts = {} + }, + + { + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + opts = { + indent = { + char = '┊' + }, + scope = { + enabled = false + } + } + }, + + { + 'lewis6991/gitsigns.nvim', + opts = {} + }, + + -- { + -- 'mrjones2014/legendary.nvim', + -- dependencies = { "stevearc/dressing.nvim" }, + -- opts = {}, + -- init = function() + -- vim.keymap.set('', '<F9>', vim.cmd.Legendary) + -- end + -- }, + + -- { + -- 'KabbAmine/zeavim.vim', + -- init = function() + -- vim.keymap.set('', '<F1>', vim.cmd.Zeavim) + -- end + -- } + + -- {'jiangmiao/auto-pairs'}, + + -- {'rafamadriz/neon'}, + + -- { + -- 'numToStr/Comment.nvim', + -- opts = {} + -- }, + + -- { + -- 'wfxr/minimap.vim', + -- dependencies = { + -- 'tanvirtin/monokai.nvim' + -- }, + -- init = function() + -- vim.g.minimap_highlight_range = 0 + -- vim.g.minimap_git_colors = 0 + -- vim.keymap.set('', '<F3>', vim.cmd.MinimapToggle) + -- end + -- }, +} diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..e365000 --- /dev/null +++ b/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,40 @@ +return { + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-vsnip', + 'hrsh7th/vim-vsnip' + }, + main = 'cmp', + opts = function() + local cmp = require('cmp') + return { + completion = { + autocomplete = false + }, + snippet = { + expand = function (args) + vim.fn["vsnip#anonymous"](args.body) + end + }, + mapping = cmp.mapping.preset.insert({ + ['<C-Space>'] = function() + if cmp.visible() then + cmp.close() + else + cmp.complete() + end + end, + ['<C-e>'] = cmp.mapping.abort(), + ['<CR>'] = cmp.mapping.confirm({ select = true }) + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'buffer' } + }) + } + end + } +} diff --git a/nvim/lua/plugins/nvim-lspconfig.lua b/nvim/lua/plugins/nvim-lspconfig.lua new file mode 100644 index 0000000..0be2f98 --- /dev/null +++ b/nvim/lua/plugins/nvim-lspconfig.lua @@ -0,0 +1,18 @@ +return { + { + 'neovim/nvim-lspconfig', + init = function() + -- vim.lsp.config('lua_ls', { + -- cmd = {'lua-language-server'}, + -- filetypes = {'lua'}, + -- root_markers = {'.luarc.json', '.git'} + -- }) + + -- vim.lsp.config('clangd', { + -- cmd = {'clangd', '--header-insertion=never'} + -- }) + + vim.lsp.enable('lua_ls') + end + } +} diff --git a/nvim/lua/plugins/nvim-tree.lua b/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..9cad99a --- /dev/null +++ b/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,47 @@ +return { + { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons' + }, + opts = { + filters = { + dotfiles = false + }, + update_focused_file = { + enable = true + }, + renderer = { + icons = { + webdev_colors = true, + git_placement = 'signcolumn' + }, + highlight_git = 'name' + }, + view = { + signcolumn = 'yes' + }, + actions = { + change_dir = { + global = true + } + }, + live_filter = { + always_show_folders = false + }, + git = { + ignore = false + } + }, + init = function() + -- vim.api.nvim_create_autocmd({"VimEnter"}, { + -- callback = function() + -- require("nvim-tree.api").tree.open() + -- end + -- }) + + vim.keymap.set('n', '<leader>tt', vim.cmd.NvimTreeToggle, {desc = "Toggle tree (nvim-tree)"}) + end + } +} diff --git a/nvim/lua/plugins/nvim-treesitter.lua b/nvim/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..ba79956 --- /dev/null +++ b/nvim/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,14 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + opts = { + ensure_installed = { + 'python', 'bash', 'lua', 'javascript', 'c', 'json', 'html' + }, + highlight = { + enable = true + } + } + } +} diff --git a/nvim/lua/plugins/outline.lua b/nvim/lua/plugins/outline.lua new file mode 100644 index 0000000..cecd7b3 --- /dev/null +++ b/nvim/lua/plugins/outline.lua @@ -0,0 +1,23 @@ +return { + -- { + -- 'majutsushi/tagbar', + -- init = function() + -- vim.keymap.set('n', '<leader>to', vim.cmd.TagbarToggle, {desc = 'Toggle outline (tagbar)'}) + -- end + -- } + { + "hedyhli/outline.nvim", + dependencies = { + 'epheien/outline-treesitter-provider.nvim', + 'epheien/outline-ctags-provider.nvim' + }, + opts = { + providers = { + priority = {'lsp', 'ctags', 'treesitter'} + } + }, + init = function() + vim.keymap.set('n', '<leader>to', vim.cmd.Outline, {desc = 'Toggle outline (outline)'}) + end + } +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..67d55bd --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,31 @@ +return { + { + 'nvim-telescope/telescope.nvim', + dependencies = { + 'BurntSushi/ripgrep', + 'nvim-lua/plenary.nvim', + 'cljoly/telescope-repo.nvim' + }, + opts = { + extensions = { + repo = { + list = { + search_dirs = { '~/repos' } + } + } + } + }, + init = function() + local telescope = require('telescope') + local builtin = require('telescope.builtin') + telescope.load_extension('repo') + vim.keymap.set('n', '<leader>ff', builtin.find_files, {desc = 'Find files'}) + vim.keymap.set('n', '<leader>fg', builtin.live_grep, {desc = 'Live grep'}) + vim.keymap.set('n', '<leader>fb', builtin.buffers, {desc = 'List buffers'}) + vim.keymap.set('n', '<leader>fh', builtin.help_tags, {desc = 'List help tags'}) + vim.keymap.set('n', '<leader>fr', telescope.extensions.repo.list, {desc = 'List repos'}) + vim.keymap.set('n', '<leader>fc', builtin.commands, {desc = 'List commands'}) + vim.keymap.set('n', '<leader>fk', builtin.keymaps, {desc = 'List keymaps'}) + end + } +} diff --git a/nvim/lua/plugins/undotree.lua b/nvim/lua/plugins/undotree.lua new file mode 100644 index 0000000..2e8aad2 --- /dev/null +++ b/nvim/lua/plugins/undotree.lua @@ -0,0 +1,9 @@ +return { + { + 'mbbill/undotree', + init = function() + vim.g.undotree_WindowLayout = 4 + vim.keymap.set('n', '<leader>tu', vim.cmd.UndotreeToggle, {desc = 'Toggle undo (undotree)'}) + end + } +} diff --git a/nvim/lua/plugins/which-key.lua b/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..ca741e3 --- /dev/null +++ b/nvim/lua/plugins/which-key.lua @@ -0,0 +1,18 @@ +return { + { + "folke/which-key.nvim", + opts = { + spec = { + {'<leader>t', group = 'toggle'} + } + }, + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 500 + + vim.keymap.set('n', '<leader>?', function() + require("which-key").show({global = true}) + end, {desc = 'Global keymaps (which-key)'}) + end + } +} |
