aboutsummaryrefslogtreecommitdiffstats
path: root/.config/nvim
diff options
context:
space:
mode:
authorSimen A. W. Olsen <so@bjerk.io>2023-12-11 13:50:30 +0100
committerSimen A. W. Olsen <so@bjerk.io>2023-12-11 13:50:30 +0100
commit4a2edf5a0f86ce3be0f8124cdb4dcad788f4784e (patch)
tree703b09f61e7680be276c66fd651f247affa9f1c1 /.config/nvim
parentfb4b39e669c8a4aadd6acfb154d42788f6bff881 (diff)
downloaddotfiles-4a2edf5a0f86ce3be0f8124cdb4dcad788f4784e.tar.gz
dotfiles-4a2edf5a0f86ce3be0f8124cdb4dcad788f4784e.zip
neovim and stuff
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/after/plugin/lsp.lua61
-rw-r--r--.config/nvim/after/plugin/treesitter.lua22
-rw-r--r--.config/nvim/init.lua1
-rw-r--r--.config/nvim/lazy-lock.json14
-rw-r--r--.config/nvim/lua/simenandre/init.lua39
-rw-r--r--.config/nvim/lua/simenandre/lazy.lua12
-rw-r--r--.config/nvim/lua/simenandre/set.lua32
7 files changed, 181 insertions, 0 deletions
diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua
new file mode 100644
index 0000000..718acae
--- /dev/null
+++ b/.config/nvim/after/plugin/lsp.lua
@@ -0,0 +1,61 @@
+local lsp = require("lsp-zero")
+
+lsp.preset("recommended")
+
+lsp.ensure_installed({
+ 'tsserver',
+ 'rust_analyzer',
+ 'astro-language-server'
+})
+
+-- Fix Undefined global 'vim'
+lsp.nvim_workspace()
+
+
+local cmp = require('cmp')
+local cmp_select = {behavior = cmp.SelectBehavior.Select}
+local cmp_mappings = lsp.defaults.cmp_mappings({
+ ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
+ ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
+ ['<C-y>'] = cmp.mapping.confirm({ select = true }),
+ ["<C-Space>"] = cmp.mapping.complete(),
+})
+
+cmp_mappings['<Tab>'] = nil
+cmp_mappings['<S-Tab>'] = nil
+
+lsp.setup_nvim_cmp({
+ mapping = cmp_mappings
+})
+
+lsp.set_preferences({
+ suggest_lsp_servers = false,
+ sign_icons = {
+ error = 'E',
+ warn = 'W',
+ hint = 'H',
+ info = 'I'
+ }
+})
+
+lsp.on_attach(function(client, bufnr)
+ local opts = {buffer = bufnr, remap = false}
+
+ vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
+ vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
+ vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
+ vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
+ vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
+ vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
+ vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
+ vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
+ vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
+ vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
+end)
+
+lsp.setup()
+
+vim.diagnostic.config({
+ virtual_text = true
+})
+
diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua
new file mode 100644
index 0000000..ddc9eef
--- /dev/null
+++ b/.config/nvim/after/plugin/treesitter.lua
@@ -0,0 +1,22 @@
+require'nvim-treesitter.configs'.setup {
+ -- A list of parser names, or "all"
+ ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" },
+
+ -- Install parsers synchronously (only applied to `ensure_installed`)
+ sync_install = false,
+
+ -- Automatically install missing parsers when entering buffer
+ -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
+ auto_install = true,
+
+ highlight = {
+ -- `false` will disable the whole extension
+ enable = true,
+
+ -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
+ -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
+ -- Using this option may slow down your editor, and you may see some duplicate highlights.
+ -- Instead of true it can also be a list of languages
+ additional_vim_regex_highlighting = false,
+ },
+}
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
new file mode 100644
index 0000000..c7ebd7e
--- /dev/null
+++ b/.config/nvim/init.lua
@@ -0,0 +1 @@
+require("simenandre")
diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json
new file mode 100644
index 0000000..db5c4d4
--- /dev/null
+++ b/.config/nvim/lazy-lock.json
@@ -0,0 +1,14 @@
+{
+ "LuaSnip": { "branch": "master", "commit": "954c81b53989097faaff0fabc11c29575288c3e1" },
+ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
+ "copilot.vim": { "branch": "release", "commit": "2c31989063b145830d5f0bea8ab529d2aef2427b" },
+ "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
+ "lsp-zero.nvim": { "branch": "v2.x", "commit": "ffebf6f7b0649f1eb81b37c37b75552f8ff96337" },
+ "mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" },
+ "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
+ "nvim-cmp": { "branch": "main", "commit": "41d7633e4146dce1072de32cea31ee31b056a131" },
+ "nvim-lspconfig": { "branch": "master", "commit": "bd405e45c5fb122c16af8f87fa2dd7ab1981b243" },
+ "nvim-treesitter": { "branch": "master", "commit": "a6c655629cad421e432aa84af32cbfe35375113a" },
+ "rose-pine": { "branch": "main", "commit": "92762f4fa2144c05db760ea254f4c399a56a7ef5" },
+ "vim-be-good": { "branch": "master", "commit": "c290810728a4f75e334b07dc0f3a4cdea908d351" }
+} \ No newline at end of file
diff --git a/.config/nvim/lua/simenandre/init.lua b/.config/nvim/lua/simenandre/init.lua
new file mode 100644
index 0000000..2382eee
--- /dev/null
+++ b/.config/nvim/lua/simenandre/init.lua
@@ -0,0 +1,39 @@
+require("simenandre.lazy")
+require("simenandre.set")
+
+vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
+
+require("lazy").setup({
+ "ThePrimeagen/vim-be-good",
+ {
+ 'rose-pine/neovim',
+ name = 'rose-pine',
+ config = function()
+ vim.cmd('colorscheme rose-pine')
+ end
+ },
+ {
+ 'VonHeikemen/lsp-zero.nvim',
+ branch = 'v2.x',
+ dependencies = {
+ -- LSP Support
+ {'neovim/nvim-lspconfig'}, -- Required
+ {'williamboman/mason.nvim'}, -- Optional
+ {'williamboman/mason-lspconfig.nvim'}, -- Optional
+
+ -- Autocompletion
+ {'hrsh7th/nvim-cmp'}, -- Required
+ {'hrsh7th/cmp-nvim-lsp'}, -- Required
+ {'L3MON4D3/LuaSnip'}, -- Required
+ }
+ },
+ {
+ "nvim-treesitter/nvim-treesitter",
+ run = function()
+ local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
+ ts_update()
+ end
+ },
+ "github/copilot.vim"
+})
+
diff --git a/.config/nvim/lua/simenandre/lazy.lua b/.config/nvim/lua/simenandre/lazy.lua
new file mode 100644
index 0000000..d14f916
--- /dev/null
+++ b/.config/nvim/lua/simenandre/lazy.lua
@@ -0,0 +1,12 @@
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not vim.loop.fs_stat(lazypath) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable", -- latest stable release
+ lazypath,
+ })
+end
+vim.opt.rtp:prepend(lazypath)
diff --git a/.config/nvim/lua/simenandre/set.lua b/.config/nvim/lua/simenandre/set.lua
new file mode 100644
index 0000000..039e58c
--- /dev/null
+++ b/.config/nvim/lua/simenandre/set.lua
@@ -0,0 +1,32 @@
+vim.opt.guicursor = ""
+
+vim.opt.nu = true
+vim.opt.relativenumber = true
+
+vim.opt.tabstop = 2
+vim.opt.softtabstop = 4
+vim.opt.shiftwidth = 2
+vim.opt.expandtab = true
+
+vim.opt.smartindent = true
+
+vim.opt.wrap = false
+
+vim.opt.swapfile = false
+vim.opt.backup = false
+vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
+vim.opt.undofile = true
+
+vim.opt.hlsearch = false
+vim.opt.incsearch = true
+
+vim.opt.termguicolors = true
+
+vim.opt.scrolloff = 8
+vim.opt.signcolumn = "yes"
+vim.opt.isfname:append("@-@")
+
+vim.opt.updatetime = 50
+
+vim.opt.colorcolumn = "80"
+