Initial commit

This commit is contained in:
2023-08-31 21:58:22 +02:00
parent 61336de4d2
commit 429a03c710
72 changed files with 5130 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
--[[
Copyright 2023 Oscar Wallberg
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]
local function term_close()
-- Split previous buffer, switching to it
vim.fn.execute("split " .. vim.fn.expand("#"))
-- Close previous window (terminal)
vim.fn.execute(vim.fn.winnr("#") .. "wincmd q")
end
vim.api.nvim_create_autocmd("TermClose", {
pattern = "term://*",
callback = term_close
})
local function my_hl()
-- example (default visual)
-- highlight Visual guifg=NONE guibg=#264F78 gui=none
-- highlight DiffDelete guifg=#414141 guibg=#1E1E1E gui=none
-- highlight GitSignsChange guifg=#0C7D9D
-- highlight IndentBlanklineContextChar guifg=#999999
-- semshi (python highlights)
-- highlight semshiLocal ctermfg=209 guifg=#ff875f
-- highlight semshiGlobal guifg=#dcdcaa
-- highlight semshiImported guifg=#4ec9b0
-- highlight semshiParameter guifg=#9cdcfe
-- highlight semshiParameterUnused guifg=#72a1bb
-- highlight semshiFree ctermfg=218 guifg=#ffafd7
-- highlight semshiBuiltin ctermfg=207 guifg=#dcdcaa
-- highlight semshiAttribute ctermfg=49 guifg=#00ffaf
-- highlight semshiSelf ctermfg=249 guifg=#dcdcaa
-- highlight semshiUnresolved ctermfg=226 guifg=#ffff00 cterm=underline gui=underline
-- highlight semshiSelected ctermfg=231 guifg=#ffffff ctermbg=161 guibg=#d7005f
-- highlight semshiErrorSign ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000
-- highlight semshiErrorChar ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000
-- sign define semshiError text=E> texthl=semshiErrorSign
end
vim.api.nvim_create_augroup("my_colors", { clear = true })
vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
callback = my_hl,
group = "my_colors"
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "go",
callback = function()
vim.opt_local.tabstop = 4
vim.opt_local.expandtab = false
vim.opt_local.listchars = 'tab:▏ '
vim.opt_local.list = true
end
})
+33
View File
@@ -0,0 +1,33 @@
--[[
Copyright 2023 Oscar Wallberg
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]
vim.g.is_win = vim.fn.has('win32') == 1 or vim.fn.has('win64') == 1
vim.g.is_linux = vim.fn.has('unix') == 1 and vim.fn.has('win64') ~= 1
vim.g.is_mac = vim.fn.has('macunix') == 1
if vim.fn.executable('python3') then
if vim.g.is_win then
vim.g.python3_host_prog=string.gsub(vim.fn.exepath('python3'), '.exe$', '')
elseif vim.g.is_linux or vim.g.is_mac then
vim.g.python3_host_prog=vim.fn.exepath('python3')
end
else
error("Python 3 executable not found! You must install Python 3 and set its PATH correctly!")
end
vim.g.mapleader = " "
vim.g.vimsyn_embed = "1"
vim.fn.execute("language en_US.utf-8")
+80
View File
@@ -0,0 +1,80 @@
--[[
Copyright 2023 Oscar Wallberg
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]
local opts = { remap = false, silent = true }
local opts_expr = { remap = false, silent = true, expr = true }
--- Tab mappings ---
-- vim.keymap.set('n', "tn", ":tabnew <BAR> NvimTreeOpen<CR>", opts)
vim.keymap.set('n', "tn", ":tabnew<CR>", opts)
vim.keymap.set('n', "tq", ":tabclose<CR>", opts)
-- switch tabs with Ctrl+PgUp/Ctrl+PgDwn (default vim mapping)
--- Window mappings ---
vim.keymap.set('n', "<A-h>", ":wincmd h<CR>", opts)
vim.keymap.set('n', "<A-j>", ":wincmd j<CR>", opts)
vim.keymap.set('n', "<A-k>", ":wincmd k<CR>", opts)
vim.keymap.set('n', "<A-l>", ":wincmd l<CR>", opts)
-- Open new window in horizontal split
vim.keymap.set('n', "<C-w>h", ":new<CR>", opts)
-- Open new window in vertical split
vim.keymap.set('n', "<C-w>v", ":vnew<CR>", opts)
-- Open new window in horizontal split at bottom
vim.keymap.set('n', "<C-w><leader>", ":bo new<CR>", opts)
-- Close buffer and window
vim.keymap.set('n', "<C-w>q", ":bd<CR>", opts)
--- Buffer mappings ---
-- Navigate up/down half a screen
vim.keymap.set({'n', 'v'}, "<C-j>", "<C-d>", opts)
vim.keymap.set({'n', 'v'}, "<C-k>", "<C-u>", opts)
-- Center cursorline
vim.keymap.set('n', "<C-Space>", "zz", opts)
-- Save buffer
vim.keymap.set('n', "<C-s>", ":w<CR>", opts)
-- Cycle buffers
vim.keymap.set('n', "<C-End>", ":BufferLineCycleNext<CR>", opts)
vim.keymap.set('n', "<C-Home>", ":BufferLineCyclePrev<CR>", opts)
-- Close buffer without closing window
vim.keymap.set('n', "<leader>q", ":bp<bar>sp<bar>bn<bar>bd<CR>", opts)
--- General mappings ---
-- Remap some swedish keys for easier use
vim.keymap.set('n', "ö", "}", { remap = true })
vim.keymap.set('v', "ö", "}", { remap = true })
vim.keymap.set('n', "ä", "{", { remap = true })
vim.keymap.set('v', "ä", "{", { remap = true })
vim.keymap.set('n', ",", "]", { remap = true })
vim.keymap.set('n', ".", "[", { remap = true })
-- yank/put using named register
vim.keymap.set('n', '<leader>y', '"0y', opts)
vim.keymap.set('v', '<leader>y', '"0y', opts)
vim.keymap.set('n', '<leader>p', '"0p', opts)
vim.keymap.set('v', '<leader>p', '"0p', opts)
-- Allow exiting insert mode in terminal by hitting <ESC>
vim.keymap.set('t', "<Esc>", "<C-\\><C-n>", opts)
-- Navigate forward/backwards
vim.keymap.set('n', "<C-l>", "<C-i>", opts)
vim.keymap.set('n', "<C-h>", "<C-o>", opts)
-- Use :diffput/get instead of normal one to allow staging visual selection
vim.keymap.set('n', "<leader>dp", "&diff ? ':diffput<CR>' : '<leader>dp'", opts_expr)
vim.keymap.set('v', "<leader>dp", "&diff ? ':diffput<CR>' : '<leader>dp'", opts_expr)
vim.keymap.set('n', "<leader>do", "&diff ? ':diffget<CR>' : '<leader>do'", opts_expr)
vim.keymap.set('v', "<leader>do", "&diff ? ':diffget<CR>' : '<leader>do'", opts_expr)
-- Remove default mappings
vim.keymap.set('', "<C-LeftMouse>", "")
vim.keymap.set('', "q", "")
+89
View File
@@ -0,0 +1,89 @@
--[[
Copyright 2023 Oscar Wallberg
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]
vim.opt.cursorline = true
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.mouse = "a"
vim.opt.mousemodel = "extend"
vim.opt.fillchars:append("diff: ")
vim.opt.splitbelow = true
vim.opt.splitright = true
-- set tabline=%!MyTabLine()
vim.opt.tabstop = 8
vim.opt.softtabstop = 4
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.smarttab = false
-- Folds are configured in nvim-treesitter, but this needs to be set before
-- loading the first buffer which is not possible in nvim-treesitter.lua due to
-- lazy loading (I think)
vim.opt.foldlevelstart = 99
vim.opt.foldmethod = "indent"
vim.opt.foldignore = ""
vim.opt.guifont = "JetBrains Mono:11"
vim.opt.completeopt:append({ "menu", "menuone", "preview", "noinsert" })
-- Max number of items
vim.opt.pumheight = 20
-- pseudo transparency for completion menu
vim.opt.pumblend = 10
-- pseudo transparency for floating window
vim.opt.winblend = 5
-- set nowrap
vim.opt.clipboard:append("unnamedplus")
vim.opt.matchpairs:append({ "<:>", "':'", "\":\"" })
vim.opt.fileencoding = "utf-8"
-- Only relevant with wrap enabled (default)
vim.opt.linebreak = true
vim.opt.breakindent = true
vim.opt.showbreak = ""
-- Minimum amount of lines to show offset +/- to cursorline
vim.opt.scrolloff = 3
vim.opt.visualbell = true
vim.opt.errorbells = false
-- Persistent undo even after you close a file and re-open it
vim.opt.undofile = true
-- Insert mode key word completion setting, see :h 'compelete'
-- and https://medium.com/usevim/set-complete-e76b9f196f0f#:~:text=When%20in%20Insert%20mode%2C%20you,%2D%2D%20CTRL%2DN%20goes%20backwards.
-- kspell is only relevant if ':set spell' is toggled on, e.g. when editing
-- documents
vim.opt.complete:append("kspell")
vim.opt.complete:remove({ "w", "b", "u", "t" })
vim.opt.spelllang = "en"
-- Align indent to next multiple value of shiftwidth.
-- E.g., only insert as many spaces necessary for reaching the next shiftwidth
vim.opt.shiftround = true
-- Allow virtualedit (editing on empty spaces) in visual block mode (Ctrl+V)
vim.opt.virtualedit = "block"
-- True color support. Avoid if terminal does not support it.
vim.opt.termguicolors = true
vim.opt.signcolumn = "auto"
-- Diff options
vim.opt.diffopt = {}
-- Use vertical split by default
vim.opt.diffopt:append("vertical")
-- Insert filler lines
vim.opt.diffopt:append("filler")
-- Execute :diffoff when only one diff window remain
vim.opt.diffopt:append("closeoff")
-- Use internal diff library
vim.opt.diffopt:append("internal")
-- These make diffs easier to read, please see the following:
-- https://vimways.org/2018/the-power-of-diff/
vim.opt.diffopt:append({ "indent-heuristic", "algorithm:histogram" })
vim.fn.execute("filetype plugin on")
vim.opt.hlsearch = false
vim.opt.laststatus = 3