diff --git a/.config/nvim/after/plugin/fugitive.lua b/.config/nvim/after/plugin/fugitive.lua new file mode 100644 index 0000000..73b78b8 --- /dev/null +++ b/.config/nvim/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git); diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..72e6afd --- /dev/null +++ b/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,40 @@ +require('mason').setup({ + ui = { + border = 'rounded' + } +}) +-- Install language servers +require('mason-lspconfig').setup { + ensure_installed = { + 'lua_ls', 'clangd', 'pylsp', 'yamlls' + } +} +local lsp = require('lsp-zero').preset({}) + +lsp.on_attach(function(client, bufnr) + lsp.default_keymaps({buffer = bufnr}) +end) + +-- (Optional) Configure lua language server for neovim +require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) + +lsp.setup() + +local cmp = require('cmp') +local cmp_action= require('lsp-zero').cmp_action() + +-- configure auto complete key +cmp.setup({ + mapping = { + [''] = cmp_action.tab_complete(), + [''] = cmp_action.select_prev_or_fallback(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.scroll_docs(1), + [''] = cmp.mapping.scroll_docs(-1), + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, +}) diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua index 246ced0..5a8068b 100644 --- a/.config/nvim/after/plugin/treesitter.lua +++ b/.config/nvim/after/plugin/treesitter.lua @@ -1,4 +1,4 @@ -require'nvim-treesitter.configs'.setup { +require('nvim-treesitter.configs').setup { -- A list of parser names, or "all" (the five listed parsers should always be installed) ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "cpp", "python", "yaml" }, diff --git a/.config/nvim/lua/lennartalff/init.lua b/.config/nvim/lua/lennartalff/init.lua index d3da885..d46d867 100644 --- a/.config/nvim/lua/lennartalff/init.lua +++ b/.config/nvim/lua/lennartalff/init.lua @@ -1,2 +1,4 @@ -require("lennartalff.remap") -print("hello from my package") +require('lennartalff.remap') +require('lennartalff.packer') +require('lennartalff.set') +vim.cmd('colorscheme rose-pine') diff --git a/.config/nvim/lua/lennartalff/packer.lua b/.config/nvim/lua/lennartalff/packer.lua index f4361f7..7bf8b7d 100644 --- a/.config/nvim/lua/lennartalff/packer.lua +++ b/.config/nvim/lua/lennartalff/packer.lua @@ -1,22 +1,43 @@ vim.cmd [[packadd packer.nvim]] return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.1', - -- or , branch = '0.1.x', - requires = { {'nvim-lua/plenary.nvim'} } - } - use({ 'rose-pine/neovim', as = 'rose-pine' }) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.1', + -- or , branch = '0.1.x', + requires = { {'nvim-lua/plenary.nvim'} } + } + use({ 'rose-pine/neovim', as = 'rose-pine' }) - vim.cmd('colorscheme rose-pine') - use { - 'nvim-treesitter/nvim-treesitter', - run = function() - local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) - ts_update() - end, - } + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end, + } + use 'tpope/vim-fugitive' + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, -- Required + { -- Optional + 'williamboman/mason.nvim', + run = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + {'williamboman/mason-lspconfig.nvim'}, -- Optional + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, -- Required + {'hrsh7th/cmp-nvim-lsp'}, -- Required + {'L3MON4D3/LuaSnip'}, -- Required + {'mhartington/formatter.nvim'}, + } +} end) diff --git a/.config/nvim/lua/lennartalff/remap.lua b/.config/nvim/lua/lennartalff/remap.lua index b760350..fca9097 100644 --- a/.config/nvim/lua/lennartalff/remap.lua +++ b/.config/nvim/lua/lennartalff/remap.lua @@ -1,2 +1,34 @@ vim.g.mapleader = " " vim.keymap.set("n", "pv", vim.cmd.Ex) + +-- move selected text +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") + +vim.keymap.set('n', 'J', 'mzJ`z') + +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') + +-- yank to clipboard +vim.keymap.set('n', 'y', '"+y') +vim.keymap.set('v', 'y', '"+y') + +-- delete to void +vim.keymap.set('n', 'd', '"_d') +vim.keymap.set('v', 'd', '"_d') + +vim.keymap.set('i', '', '') + +-- avoid accidentally closing everything! +vim.keymap.set('n', 'Q', '') + +vim.keymap.set('n', 'f', function() + vim.lsp.buf.format() +end) + +-- quickfix navigation +vim.keymap.set('n', '', 'cnextzz') +vim.keymap.set('n', '', 'cprevzz') +vim.keymap.set('n', 'k', 'lnextzz') +vim.keymap.set('n', 'j', 'lprevzz') diff --git a/.config/nvim/lua/lennartalff/set.lua b/.config/nvim/lua/lennartalff/set.lua new file mode 100644 index 0000000..45e3b64 --- /dev/null +++ b/.config/nvim/lua/lennartalff/set.lua @@ -0,0 +1,21 @@ +vim.opt.guicursor = '' + +-- line numbers +vim.opt.nu = true +vim.opt.relativenumber = true + +-- default indentation +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = 'yes' +vim.opt.updatetime = 500 +vim.opt.colorcolumn = '80' + diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 9da6439..f0160cd 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -74,6 +74,46 @@ end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { + LuaSnip = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["formatter.nvim"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/formatter.nvim", + url = "https://github.com/mhartington/formatter.nvim" + }, + ["lsp-zero.nvim"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim", + url = "https://github.com/VonHeikemen/lsp-zero.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, ["nvim-treesitter"] = { loaded = true, path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/nvim-treesitter", @@ -98,6 +138,11 @@ _G.packer_plugins = { loaded = true, path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["vim-fugitive"] = { + loaded = true, + path = "/home/lennartalff/.local/share/nvim/site/pack/packer/start/vim-fugitive", + url = "https://github.com/tpope/vim-fugitive" } }