speedie-nvim | Add new config

This commit is contained in:
Jacob 2024-01-19 11:29:06 +01:00
parent c4b7c37c9a
commit 169148fc14
6 changed files with 344 additions and 30 deletions

13
.config/nvim/.luarc.json Normal file
View file

@ -0,0 +1,13 @@
{
"runtime.version": "LuaJIT",
"runtime.path": [
"lua/?.lua",
"lua/?/init.lua"
],
"diagnostics.globals": ["vim"],
"workspace.checkThirdParty": false,
"workspace.library": [
"$VIMRUNTIME",
"./lua"
]
}

View file

@ -3,14 +3,44 @@
-- https://git.speedie.site/speedie/speedie-nvim --
]]--
require('bootstrap')
local cmd = vim.cmd
local opt = vim.opt
local o = vim.o
local api = vim.api
local keymap = vim.api.nvim_set_keymap
local autocmd = vim.api.nvim_create_autocmd
local sessionFile = vim.fn.expand('~/.config/nvim/.session.nvim')
require("lazy").setup({
{ 'nvim-telescope/telescope.nvim', dependencies = {
'nvim-lua/plenary.nvim',
} }, -- Fuzzy-finding
{ 'nvim-lualine/lualine.nvim' }, -- Status line
{ 'm4xshen/autoclose.nvim' }, -- Autoclose brackets
{ 'romgrk/doom-one.vim' }, -- Doom-One theme
{ 'stevearc/conform.nvim' }, -- Formatting
{ 'romgrk/barbar.nvim',
dependencies = {
'lewis6991/gitsigns.nvim',
'nvim-tree/nvim-web-devicons',
}, opts = {
clickable = true,
animation = true,
focus_on_close = 'left',
} }, -- Tabs
{ 'williamboman/mason.nvim',
dependencies = {
'williamboman/mason-lspconfig.nvim',
} }, -- Server auto-install
{ 'VonHeikemen/lsp-zero.nvim', branch = 'v3.x', dependencies = {
'neovim/nvim-lspconfig',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/nvim-cmp',
'L3MON4D3/LuaSnip',
} }, -- LSP
})
opt.title = true -- Display title
opt.spelllang = 'en_us' -- Use English (United States) as spellcheck language by default
opt.relativenumber = true -- Show relative line numbers
@ -25,7 +55,7 @@ opt.smartindent = true -- Automatically indent the next line
opt.autoindent = true -- Pretty much same for this one
opt.expandtab = true -- Replace tabs with spaces automatically
opt.swapfile = false -- Don't use a swapfile
opt.cursorline = false -- Don't show the cursor line
opt.cursorline = true -- Show the cursor line
opt.undolevels = 10000 -- Allow up to 10000 undos
opt.tabstop = 4 -- Display a tab (\t) as 4 spaces
opt.softtabstop = 4 -- Display a tab (\t) as 4 spaces
@ -41,45 +71,67 @@ o.t_8f = '\27[38;2;%lu;%lu;%lum' -- To be honest, I don't know what this does bu
o.t_8b = '\27[48;2;%lu;%lu;%lum' -- To be honest, I don't know what this does but if I remember correctly it's something good.
cmd([[
colorscheme elflord
colorscheme doom-one
highlight Normal ctermfg=grey ctermbg=lightgray guifg=#ffffff guibg=#222222
highlight EndOfBuffer ctermfg=grey ctermbg=lightgray guifg=#ffffff guibg=#222222
highlight Folded ctermfg=grey ctermbg=lightgray guifg=#afeeee guibg=#333333
highlight SpellBad guisp=red gui=undercurl guifg=none guibg=none ctermfg=none ctermbg=none term=underline cterm=undercurl
highlight SpellCap guisp=yellow gui=undercurl guifg=none guibg=none ctermfg=none ctermbg=none term=underline cterm=undercurl
filetype plugin indent on
]])
keymap('n', '<C-h>', '<C-w>h', { noremap = true })
keymap('n', '<C-j>', '<C-w>j', { noremap = true })
keymap('n', '<C-k>', '<C-w>k', { noremap = true })
keymap('n', '<C-l>', '<C-w>l', { noremap = true })
keymap('n', '<C-s>', ':split<CR>', { noremap = true })
keymap('n', '<C-w>', ':vsplit<CR>', { noremap = true })
keymap('n', '<C-q>', ':only<CR>', { noremap = true })
keymap('n', '<C-t>', ':term<CR>', { noremap = true })
keymap('n', '<F2>', ':set spell!<CR>', { noremap = true })
keymap('n', '<F3>', ':set spelllang=en_us<CR>', { noremap = true })
keymap('n', '<F4>', ':set spelllang=sv_se<CR>', { noremap = true })
keymap('n', '<F7>', ':silent execute "!setxkbmap us"<CR>', { noremap = true })
keymap('n', '<F8>', ':silent execute "!setxkbmap se"<CR>', { noremap = true })
keymap('n', '<C-R>', '[sz=', { noremap = true })
keymap('n', '<C-e>', 'z=', { noremap = true })
keymap('n', '<C-b>', ':!ninja -C build<CR>', { noremap = true })
keymap('n', 'H', ':vertical resize -10<CR>', { noremap = true })
keymap('n', 'J', ':resize -10<CR>', { noremap = true })
keymap('n', 'K', ':resize +10<CR>', { noremap = true })
keymap('n', 'L', ':vertical resize +10<CR>', { noremap = true })
keymap('n', 'd', '"_d', { noremap = true })
keymap('x', 'd', '"_d', { noremap = true })
keymap('x', 'p', '"_dP', { noremap = true })
keymap('n', 'c', '"_c', { noremap = true })
keymap('n', '<C-A>', 'v/{<cr>%', { noremap = true })
keymap('n', '<C-h>', '<C-w>h', { noremap = true, silent = true })
keymap('n', '<C-j>', '<C-w>j', { noremap = true, silent = true })
keymap('n', '<C-k>', '<C-w>k', { noremap = true, silent = true })
keymap('n', '<C-l>', '<C-w>l', { noremap = true, silent = true })
keymap('n', '<C-s>', ':split<cr>', { noremap = true, silent = true })
keymap('n', '<C-w>', ':vsplit<cr>', { noremap = true, silent = true })
keymap('n', '<C-q>', ':only<cr>', { noremap = true, silent = true })
keymap('n', '<C-t>', ':term<cr>', { noremap = true, silent = true })
keymap('n', '<C-f>', ':Telescope fd<cr>', { noremap = true, silent = true })
keymap('n', '<F2>', ':set spell!<cr>', { noremap = true, silent = true })
keymap('n', '<F3>', ':set spelllang=en_us<cr>', { noremap = true, silent = true })
keymap('n', '<F4>', ':set spelllang=sv_se<cr>', { noremap = true, silent = true })
keymap('n', '<F7>', ':silent execute "!setxkbmap us"<cr>', { noremap = true, silent = true })
keymap('n', '<F8>', ':silent execute "!setxkbmap se"<cr>', { noremap = true, silent = true })
keymap('n', '<C-e>', 'z=', { noremap = true, silent = true })
keymap('n', '<C-b>', ':!ninja -C build<cr>', { noremap = true, silent = true })
keymap('n', 'H', ':vertical resize -10<cr>', { noremap = true, silent = true })
keymap('n', 'J', ':resize -10<cr>', { noremap = true, silent = true })
keymap('n', 'K', ':resize +10<cr>', { noremap = true, silent = true })
keymap('n', 'L', ':vertical resize +10<cr>', { noremap = true, silent = true })
keymap('n', 'd', '"_d', { noremap = true, silent = true })
keymap('x', 'd', '"_d', { noremap = true, silent = true })
keymap('x', 'p', '"_dP', { noremap = true, silent = true })
keymap('n', 'c', '"_c', { noremap = true, silent = true })
keymap('n', '<C-A>', 'v/{<cr>%', { noremap = true, silent = true })
keymap('n', '<A-,>', '<Cmd>BufferPrevious<cr>', { noremap = true, silent = true })
keymap('n', '<A-.>', '<Cmd>BufferNext<cr>', { noremap = true, silent = true })
keymap('n', '<A-<>', '<Cmd>BufferMovePrevious<cr>', { noremap = true, silent = true })
keymap('n', '<A->>', '<Cmd>BufferMoveNext<cr>', { noremap = true, silent = true })
keymap('n', '<A-1>', '<Cmd>BufferGoto 1<cr>', { noremap = true, silent = true })
keymap('n', '<A-2>', '<Cmd>BufferGoto 2<cr>', { noremap = true, silent = true })
keymap('n', '<A-3>', '<Cmd>BufferGoto 3<cr>', { noremap = true, silent = true })
keymap('n', '<A-4>', '<Cmd>BufferGoto 4<cr>', { noremap = true, silent = true })
keymap('n', '<A-5>', '<Cmd>BufferGoto 5<cr>', { noremap = true, silent = true })
keymap('n', '<A-6>', '<Cmd>BufferGoto 6<cr>', { noremap = true, silent = true })
keymap('n', '<A-7>', '<Cmd>BufferGoto 7<cr>', { noremap = true, silent = true })
keymap('n', '<A-8>', '<Cmd>BufferGoto 8<cr>', { noremap = true, silent = true })
keymap('n', '<A-9>', '<Cmd>BufferGoto 9<cr>', { noremap = true, silent = true })
keymap('n', '<A-0>', '<Cmd>BufferLast<cr>', { noremap = true, silent = true })
keymap('n', '<A-p>', '<Cmd>BufferPin<cr>', { noremap = true, silent = true })
keymap('n', '<A-c>', '<Cmd>BufferClose<cr>', { noremap = true, silent = true })
keymap('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<cr>', { noremap = true, silent = true })
keymap('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<cr>', { noremap = true, silent = true })
keymap('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<cr>', { noremap = true, silent = true })
keymap('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<cr>', { noremap = true, silent = true })
function saveSession() -- Save the current session
local function saveSession() -- Save the current session
vim.cmd('mksession! ' .. sessionFile)
end
function restoreSession() -- Restore the last session
local function restoreSession() -- Restore the last session
if vim.fn.argc() == 0 then
if vim.fn.filereadable(sessionFile) == 1 then
vim.cmd('source ' .. sessionFile)
@ -118,3 +170,8 @@ autocmd('VimLeave', { -- Save session on exit
saveSession()
end,
})
require('lsp_config')
require('lualine_config')
require('conform').setup({})
require('autoclose').setup({})

View file

@ -0,0 +1,19 @@
{
"LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" },
"autoclose.nvim": { "branch": "main", "commit": "37e11589aac55b0e8810dc5865f898f9cb36fef6" },
"barbar.nvim": { "branch": "master", "commit": "4ba9ac54f0c5d82131905160afff94172e3325e6" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"conform.nvim": { "branch": "master", "commit": "cbc5745bf7519acaf3a5cbaaa677fd556aa813d7" },
"doom-one.vim": { "branch": "master", "commit": "323b7c31c617b153d12095e9fd9648f2fda2b646" },
"gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "dec1c21204e2d9d49dad989b577c88958ed2c113" },
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" },
"mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-lspconfig": { "branch": "master", "commit": "7eed8b2150192e5ad05e1886fdf133493ddf2928" },
"nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }
}

View file

@ -0,0 +1,18 @@
--[[
speedie's neovim configuration
-- https://git.speedie.site/speedie/speedie-nvim --
]]--
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)

View file

@ -0,0 +1,5 @@
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr) lsp_zero.default_keymaps({buffer = bufnr}) end)
require('mason').setup({})
require('mason-lspconfig').setup({handlers = { lsp_zero.default_setup }, })

View file

@ -0,0 +1,202 @@
-- Eviline config for lualine
-- Author: shadmansaleh
-- Credit: glepnir
require('lualine').setup()
local lualine = require('lualine')
-- Color table for highlights
-- stylua: ignore
local colors = {
bg = '#202328',
fg = '#bbc2cf',
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand('%:p:h')
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
-- Disable sections and component separators
component_separators = '',
section_separators = '',
theme = {
-- We are going to use lualine_c an lualine_x as left and
-- right section. Both are highlighted by c theme . So we
-- are just setting default looks o statusline
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x at right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
return ''
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- We don't need space before this
}
ins_left {
-- mode component
function()
return ''
end,
color = function()
-- auto change color according to neovims mode
local mode_color = {
n = colors.red,
i = colors.green,
v = colors.blue,
[''] = colors.blue,
V = colors.blue,
c = colors.magenta,
no = colors.red,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.violet,
Rv = colors.violet,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
t = colors.red,
}
return { fg = mode_color[vim.fn.mode()] }
end,
padding = { right = 1 },
}
ins_left {
-- filesize component
'filesize',
cond = conditions.buffer_not_empty,
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.magenta, gui = 'bold' },
}
ins_left { 'location' }
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
},
}
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
function()
return '%='
end,
}
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- I'm not sure why it's upper case either ;)
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'fileformat',
fmt = string.upper,
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
-- Is it me or the symbol for modified us really weird
symbols = { added = '', modified = '󰝤 ', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
ins_right {
function()
return ''
end,
color = { fg = colors.blue },
padding = { left = 1 },
}
-- Now don't forget to initialize lualine
lualine.setup(config)