Compare commits

..

11 Commits

Author SHA1 Message Date
Fabian Schmidt
aa72c826c0 Moved lsp config into plugin file 2023-02-26 13:20:49 +01:00
Fabian Schmidt
717c7f09e5 First draft after switching to lazy.nvim 2023-02-24 21:11:27 +01:00
Fabian Schmidt
6a51019731 Don't remember what smartindent = true does
Theme looks like shit for html
Added tailwindcss lsp for future use
Add diagnostics shortcuts
2023-02-02 11:30:29 +01:00
Fabian Schmidt
7cffe20d81 Darcula looks weid since last (treesitter?) upgrade. Added a few colorschemes and shortcut to access them 2022-10-29 14:22:42 +02:00
Fabian Schmidt
966adc7817 Update cmp. Add sql, html and css lsp functionality. Add snippet for go error handling. Enable Treesitter for syntax highlighting 2022-10-26 12:39:08 +02:00
Fabian Schmidt
fe9da6af57 Add bashls and format using formatter built into lua lsp 2022-10-18 17:42:03 +02:00
Fabian Schmidt
a8818ea92a I honestly don't know anymore 2022-10-13 17:31:11 +02:00
Fabian Schmidt
bebd4c1ff9 I did way too much in this one commit
Vimconf2021 inspired me a lot and I'm not done yet
2021-11-26 23:38:04 +01:00
Fabian Schmidt
aa4d71c989 First step toward completing IDE
Update Settings to make lualine work again
Disable treesitter temporarily
2021-07-14 14:17:19 +02:00
Fabian Schmidt
c1516e7018 Install nvim-tree and telescope. Configure undofile. Some minor changes 2021-03-02 16:11:31 +01:00
Fabian Schmidt
54181f1123 Added script to more easily start nvim with init.lua 2021-03-02 10:51:52 +01:00
13 changed files with 482 additions and 106 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
spell/

View File

@@ -1,7 +1,45 @@
-- init.lua -- init.lua
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)
vim.g.mapleader = " "
require("lazy").setup("plugins")
require("maps").init()
require("commands")
require('lua/plugins') vim.opt.backup = false
require('lua/settings') vim.opt.undodir = '/Users/fschmidt/.cache/nvim/undodir'
require('lua/maps') vim.opt.swapfile = false
require('lua/commands') vim.opt.undofile = true
require('lua/utils') vim.opt.smartcase = true
vim.opt.ignorecase = true
vim.opt.laststatus = 2
vim.opt.hidden = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.scrolloff = 12
vim.opt.sidescrolloff = 8
vim.opt.mouse = 'a'
vim.opt.autochdir = true
vim.opt.clipboard = 'unnamed,unnamedplus'
vim.opt.number = true
vim.opt.wrap = false
vim.opt.signcolumn = 'yes:2'
vim.opt.list = true
vim.opt.listchars = 'tab:▸ ,trail:·'
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = false
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.completeopt = { "menu", "menuone", "noselect" }

31
lazy-lock.json Normal file
View File

@@ -0,0 +1,31 @@
{
"LuaSnip": { "branch": "master", "commit": "f7c845749aba6096f041a73a26ba64f3817bab99" },
"bufferline.nvim": { "branch": "main", "commit": "52d6acabb79c8c0942f8873a0ca7848eb2159267" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8fcc934a52af96120fe26358985c10c035984b53" },
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" },
"cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"dashboard-nvim": { "branch": "master", "commit": "398ba8d9390c13c87a964cbca756319531fffdb7" },
"fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" },
"gitsigns.nvim": { "branch": "main", "commit": "f388995990aba04cfdc7c3ab870c33e280601109" },
"kanagawa.nvim": { "branch": "master", "commit": "4c8d48726621a7f3998c7ed35b2c2535abc22def" },
"lazy.nvim": { "branch": "main", "commit": "8077428e63feb0f3bf795d53b23ba1695b28ab0e" },
"lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" },
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "3f9c0ea157e88b08e2d11ec65002eeb6e421f0da" },
"mason.nvim": { "branch": "main", "commit": "63cff223169324a2e633954ac580c7c327182a97" },
"nvim-autopairs": { "branch": "master", "commit": "6a5faeabdbcc86cfbf1561ae430a451a72126e81" },
"nvim-cmp": { "branch": "main", "commit": "7a3b1e76f74934b12fda82158237c6ad8bfd3d40" },
"nvim-lspconfig": { "branch": "master", "commit": "62856b20751b748841b0f3ec5a10b1e2f6a6dbc9" },
"nvim-tree.lua": { "branch": "master", "commit": "9c97e6449b0b0269bd44e1fd4857184dfa57bb4c" },
"nvim-treesitter": { "branch": "master", "commit": "b4d8b7e5a374b800838a13aa6829ac4d542c6f1c" },
"nvim-web-devicons": { "branch": "master", "commit": "4709a504d2cd2680fb511675e64ef2790d491d36" },
"playground": { "branch": "master", "commit": "4044b53c4d4fcd7a78eae20b8627f78ce7dc6f56" },
"plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
"rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" },
"telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" },
"vimwiki": { "branch": "dev", "commit": "fea8bee382b2051b0137fd2cacf0862823ee69b3" }
}

View File

@@ -1,10 +1,10 @@
-- commands.lua -- commands.lua
-- autocmd! User GoyoEnter Limelight
-- autocmd! User GoyoLeave Limelight!
-- command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
vim.cmd 'autocmd! User GoyoEnter Limelight' vim.cmd 'autocmd! User GoyoEnter Limelight'
vim.cmd 'autocmd! User GoyoLeave Limelight!' vim.cmd 'autocmd! User GoyoLeave Limelight!'
vim.cmd 'autocmd BufRead,BufNewFile *.wiki,*.md,*.tex set wrap'
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
vim.cmd 'command W :execute \':silent w !sudo tee % > /dev/null\' | :edit!' vim.cmd 'command W :execute \':silent w !sudo tee % > /dev/null\' | :edit!'

View File

@@ -1,29 +1,59 @@
-- maps.lua -- maps.lua
local maps = {}
local function map(mode, lhs, rhs, opts) local function map(mode, lhs, rhs, opts)
local options = {noremap = true} local options = { noremap = true }
if opts then options = vim.tbl_extend('force', options, opts) end if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_set_keymap(mode, lhs, rhs, options) vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end end
vim.g.mapleader = "," function maps.toggleGoyo()
-- Toggle Goyo map('n', '<C-g>', ':Goyo<Enter>', { noremap = false })
map('n', '<C-g>', ':Goyo<Enter>', {noremap = false}) end
-- Open and move to resized terminal
map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', {noremap = false}) function maps.term()
-- Enter normal mode in terminal -- Open and move to resized terminal
map('t', '¿<C-N>', '<C-\\><C-N>') map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', { noremap = false })
-- Clear highlight -- Enter normal mode in terminal
map('n', '<C-l>', '<cmd>noh<CR>') map('t', 'ß<C-N>', '<C-\\><C-N>')
-- Move to window in any mode end
-- map('t', 'ª', '<C-\\><C-N><C-w>h')
-- map('t', 'º', '<C-\\><C-N><C-w>j') function maps.telescope()
-- map('t', '∆', '<C-\\><C-N><C-w>k') map('n', '<Leader>ff', '<cmd>lua require(\'telescope.builtin\').git_files()<CR>')
-- map('t', '@', '<C-\\><C-N><C-w>l') map('n', '<Leader>fg', '<cmd>lua require(\'telescope.builtin\').live_grep()<CR>')
-- map('i', 'ª', '<C-\\><C-N><C-w>h') map('n', '<Leader>fb', '<cmd>lua require(\'telescope.builtin\').buffers()<CR>')
-- map('i', 'º', '<C-\\><C-N><C-w>j') map('n', '<Leader>fh', '<cmd>lua require(\'telescope.builtin\').help_tags()<CR>')
-- map('i', '∆', '<C-\\><C-N><C-w>k') end
-- map('i', '@', '<C-\\><C-N><C-w>l')
-- map('n', 'ª', '<C-w>h') function maps.fixIndent()
-- map('n', 'º', '<C-w>j') map('v', '<', '<gv')
-- map('n', '∆', '<C-w>k') map('v', '>', '>gv')
-- map('n', '@', '<C-w>l') end
function maps.moveByRow()
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided
map('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'', { silent = true, expr = true })
map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', { silent = true, expr = true })
end
function maps.centeredSearch()
map('n', 'n', 'nzzzv')
map('n', 'N', 'Nzzzv')
end
function maps.init()
vim.g.mapleader = " "
map('n', '<leader>b', '<cmd>NvimTreeToggle<CR>')
map('n', '<leader>cc', '<cmd>Telescope colorscheme<CR>')
maps.toggleGoyo()
maps.term()
maps.telescope()
maps.fixIndent()
maps.moveByRow()
maps.centeredSearch()
end
return maps

View File

@@ -1,18 +0,0 @@
-- plugin.lua
vim.cmd 'packadd paq-nvim'
local paq = require'paq-nvim'.paq
paq{'savq/paq-nvim', opt=true}
-- Theme
paq 'akinsho/nvim-bufferline.lua'
paq 'hoob3rt/lualine.nvim'
paq 'airblade/vim-gitgutter'
paq 'kyazdani42/nvim-web-devicons'
paq 'doums/darcula'
paq 'junegunn/goyo.vim'
paq 'junegunn/limelight.vim'
-- lsp
paq 'neovim/nvim-lspconfig'
paq 'nvim-lua/completion-nvim'

192
lua/plugins/lsp.lua Normal file
View File

@@ -0,0 +1,192 @@
local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', ',d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', '.d', vim.diagnostic.goto_next, opts)
local lsp_attach = function(client, buf)
vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()")
vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc")
vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc")
local bufopts = { noremap = true, silent = true, buffer = buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
end
return {
-- lsp
{
'williamboman/mason.nvim',
config = true
},
{
'williamboman/mason-lspconfig.nvim',
config = true
},
{
'neovim/nvim-lspconfig',
config = function()
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require('lspconfig')
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
}
}
},
on_attach = lsp_attach
}
lspconfig.tsserver.setup {
capabilities = capabilities,
on_attach = lsp_attach
}
lspconfig.gopls.setup {
capabilities = capabilities,
on_attach = lsp_attach
}
--lspconfig.rust_analyzer.setup {
-- capabilities = capabilities,
-- on_attach = lsp_attach
--}
require("rust-tools").setup({
server = {
capabilities = capabilities,
on_attach = lsp_attach,
standalone = false
}
})
lspconfig.bashls.setup {
capabilities = capabilities,
on_attach = lsp_attach
}
lspconfig.sqlls.setup({
capabilities = capabilities,
on_attach = lsp_attach
})
lspconfig.html.setup({
capabilities = capabilities,
on_attach = lsp_attach
})
lspconfig.cssls.setup({
capabilities = capabilities,
on_attach = lsp_attach
})
lspconfig.tailwindcss.setup({
capabilities = capabilities,
on_attach = lsp_attach
})
capabilities.textDocument.completion.completionItem.snippetSupport = true
lspconfig.emmet_ls.setup({
capabilities = capabilities,
on_attach = lsp_attach
})
end
},
{ 'simrat39/rust-tools.nvim' },
{ 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga
{ 'j-hui/fidget.nvim' }, -- show lsp status
-- completion
{
'hrsh7th/nvim-cmp',
config = function()
local cmp = require('cmp')
local lspkind = require('lspkind')
vim.opt.shortmess:append 'c'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-s>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true
}),
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lua' },
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'luasnip' },
{ name = 'nvim_lsp_signature_help' },
}, {
{ name = 'buffer', keyword_length = 5 },
}),
formatting = {
format = lspkind.cmp_format {
with_text = true,
menu = {
buffer = "[buf]",
nvim_lsp = "[LSP]",
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
}
}
}
})
-- Use buffer source for `/` (basically search words in buffer)
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':'
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end,
event = 'InsertEnter',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lsp-signature-help',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-nvim-lua',
'hrsh7th/cmp-cmdline',
'saadparwaiz1/cmp_luasnip',
}
},
{
'L3MON4D3/LuaSnip',
config = function()
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" })
end
},
{
'windwp/nvim-autopairs',
config = true
},
}
-- -- Linting & formtatting
-- 'jose-elias-alvarez/null-ls.nvim';

View File

@@ -0,0 +1,67 @@
return {
{
'nvim-telescope/telescope.nvim',
tag = '0.1.1',
dependencies = { 'nvim-lua/plenary.nvim' },
},
{
'nvim-tree/nvim-tree.lua',
config = function()
require('nvim-tree').setup {
disable_netrw = true,
hijack_netrw = true,
open_on_setup = false,
ignore_ft_on_setup = {},
open_on_tab = false,
hijack_cursor = false,
update_cwd = true,
hijack_directories = {
enable = true,
auto_open = true,
},
diagnostics = {
enable = false,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}
},
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
},
system_open = {
cmd = nil,
args = {}
},
filters = {
dotfiles = false,
custom = {}
},
git = {
enable = true,
ignore = true,
timeout = 500,
},
view = {
width = 30,
hide_root_folder = false,
side = 'left',
mappings = {
custom_only = false,
list = {}
}
},
actions = {
open_file = {
resize_window = false
}
}
}
end,
dependencies = { 'nvim-tree/nvim-web-devicons' }
}
}

52
lua/plugins/style.lua Normal file
View File

@@ -0,0 +1,52 @@
return {
{
'rebelot/kanagawa.nvim',
config = function()
vim.opt.guifont = 'Source Code Pro for Powerline'
vim.g.limelight_conceal_ctermfg = 'gray'
vim.cmd('colorscheme kanagawa')
vim.cmd('set termguicolors')
vim.opt.syntax = 'on'
end
},
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function()
require('nvim-treesitter.configs').setup {
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
disable = { "html" }
}
}
end,
dependencies = { 'nvim-treesitter/playground' }
},
{
'akinsho/bufferline.nvim',
tag = "v3.3.0",
config = true,
dependencies = { 'nvim-tree/nvim-web-devicons' }
},
{
'hoob3rt/lualine.nvim',
config = function()
require('lualine').setup {
options = {
theme = 'kanagawa'
}
}
end
},
{ 'lewis6991/gitsigns.nvim' },
{
'glepnir/dashboard-nvim',
event = 'VimEnter',
config = true,
dependencies = { 'nvim-tree/nvim-web-devicons' }
},
}

12
lua/plugins/writing.lua Normal file
View File

@@ -0,0 +1,12 @@
return {
-- writing
{
'vimwiki/vimwiki',
ft = { 'md', 'wiki', 'tex' },
config = function()
vim.g.vimwiki_list = { { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' } }
end
},
--{ 'junegunn/goyo.vim' }, -- try replacing these 2 at some point because they don't work that well anymore
--{ 'junegunn/limelight.vim' },
}

View File

@@ -1,54 +0,0 @@
-- settings.lua
local cmd = vim.cmd
local scopes = {o = vim.o, bo = vim.bo, wo = vim.wo}
local function opt(scope, key, value)
scopes[scope][key] = value
if scope ~= 'o' then scopes['o'][key] = value end
end
---- Misc Options
-- global options
opt('o', 'swapfile', true)
opt('o', 'dir', '/tmp')
opt('o', 'smartcase', true)
opt('o', 'laststatus', 2)
opt('o', 'hlsearch', true)
opt('o', 'incsearch', true)
opt('o', 'ignorecase', true)
opt('o', 'scrolloff', 12)
opt('o', 'mouse', 'a')
-- window-local options
opt('wo', 'number', true)
opt('wo', 'wrap', false)
-- buffer-local options
opt('bo', 'shiftwidth', 4)
opt('bo', 'tabstop', 4)
opt('bo', 'softtabstop', 4)
opt('bo', 'expandtab', true)
opt('bo', 'autoindent', true)
---- Theme
-- Font
opt('o', 'guifont', 'Source Code Pro for Powerline')
-- Statusline
local lualine = require('lualine')
lualine.status()
-- Bufferline
local bufferline = require('bufferline')
bufferline.setup()
local function ColorDarcula()
lualine.options.theme = 'onedark'
vim.g.limelight_conceal_ctermfg = 'gray'
cmd 'colorscheme darcula'
end
opt('bo', 'syntax', 'on')
ColorDarcula()

View File

25
snippets/go.lua Normal file
View File

@@ -0,0 +1,25 @@
local ls = require("luasnip")
local s = ls.s
local i = ls.i
local t = ls.t
local d = ls.dynamic_node
local c = ls.choice_node
local f = ls.function_node
local sn = ls.snippet_node
local fmt = require("luasnip.extras.fmt").fmt
local rep = require("luasnip.extras").rep
local snippets, autosnippets = {}, {}
local errorSnippet = s("error", fmt([[
if err != nil {{
{}
}}
]], {
i(1, "return nil, err")
}))
table.insert(snippets, errorSnippet)
return snippets, autosnippets