I honestly don't know anymore

This commit is contained in:
Fabian Schmidt 2022-10-13 17:31:11 +02:00
parent bebd4c1ff9
commit a8818ea92a
10 changed files with 238 additions and 83 deletions

View File

@ -1,5 +0,0 @@
#!/bin/bash
set -euo pipefail
nvim -u init.lua ${1:-.}

View File

@ -1,6 +1,6 @@
-- init.lua -- init.lua
require'plugins'.init() require'plugins'
require'settings'.init() require'settings'.init()
require'maps'.init() require'maps'.init()
require'commands' require'commands'

View File

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

View File

@ -11,6 +11,7 @@ end
function maps.toggleGoyo() function maps.toggleGoyo()
map('n', '<C-g>', ':Goyo<Enter>', {noremap = false}) map('n', '<C-g>', ':Goyo<Enter>', {noremap = false})
end end
function maps.term() function maps.term()
-- Open and move to resized terminal -- Open and move to resized terminal
map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', {noremap = false}) map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', {noremap = false})
@ -65,7 +66,7 @@ function maps.init()
maps.fixIndent() maps.fixIndent()
maps.moveByRow() maps.moveByRow()
maps.centeredSearch() maps.centeredSearch()
maps.moveToWindow() -- maps.moveToWindow()
end end
return maps return maps

View File

@ -1,49 +1,59 @@
-- plugin.lua -- plugin.lua
local plugins = {}
function plugins.load(pluginList) require "paq" {
for _, plugin in pairs(pluginList) do
require'paq-nvim'.paq(plugin)
end
end
local pluginList = {
-- Handle itself -- Handle itself
{'savq/paq-nvim', opt=true}, 'savq/paq-nvim';
-- Theme -- Theme
'kyazdani42/nvim-web-devicons', 'kyazdani42/nvim-web-devicons';
'rktjmp/lush.nvim', 'rktjmp/lush.nvim';
'briones-gabriel/darcula-solid.nvim', 'briones-gabriel/darcula-solid.nvim';
-- treesitter -- treesitter
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter';
'nvim-treesitter/playground';
-- Utils -- Utils
'akinsho/nvim-bufferline.lua', 'akinsho/nvim-bufferline.lua';
'hoob3rt/lualine.nvim', 'hoob3rt/lualine.nvim';
'airblade/vim-gitgutter', 'j-hui/fidget.nvim';
'nvim-lua/popup.nvim', 'airblade/vim-gitgutter';
'nvim-lua/plenary.nvim', 'nvim-lua/popup.nvim';
'nvim-lua/plenary.nvim';
-- File Navigation -- File Navigation
'kyazdani42/nvim-tree.lua', 'kyazdani42/nvim-tree.lua';
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim';
-- lsp -- lsp
'neovim/nvim-lspconfig', 'williamboman/mason.nvim';
'williamboman/nvim-lsp-installer', 'williamboman/mason-lspconfig.nvim';
'neovim/nvim-lspconfig';
'onsails/lspkind-nvim'; -- pictograms
'simrat39/rust-tools.nvim';
-- completion
'hrsh7th/cmp-nvim-lsp';
'hrsh7th/cmp-nvim-lsp-signature-help';
'hrsh7th/cmp-buffer';
'hrsh7th/cmp-path';
'hrsh7th/cmp-nvim-lua';
'hrsh7th/cmp-cmdline';
'hrsh7th/nvim-cmp';
-- snippets needed for cmp
'L3MON4D3/LuaSnip';
'saadparwaiz1/cmp_luasnip';
-- autopair
'windwp/nvim-autopairs';
-- Linting & formtatting
'jose-elias-alvarez/null-ls.nvim';
-- writing -- writing
'vimwiki/vimwiki', 'vimwiki/vimwiki';
'junegunn/goyo.vim', 'junegunn/goyo.vim';
'junegunn/limelight.vim', 'junegunn/limelight.vim';
} }
function plugins.init()
vim.cmd 'packadd paq-nvim'
plugins.load(pluginList)
end
return plugins

View File

@ -0,0 +1,73 @@
-- Completion
local completion = {}
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' }
})
})
-- autopair
require('nvim-autopairs').setup {}
return completion

View File

@ -28,6 +28,7 @@ function settings.initMisc()
vim.opt.softtabstop = 4 vim.opt.softtabstop = 4
vim.opt.expandtab = false vim.opt.expandtab = false
vim.opt.autoindent = true vim.opt.autoindent = true
vim.opt.completeopt = { "menu", "menuone", "noselect" }
end end
function settings.initVimWiki() function settings.initVimWiki()
@ -39,6 +40,8 @@ function settings.init()
settings.initVimWiki() settings.initVimWiki()
require'settings.theme'.init() require'settings.theme'.init()
require'settings.lsp'.init() require'settings.lsp'.init()
require'settings.completion'
require'settings.tree'
end end
return settings return settings

View File

@ -2,54 +2,60 @@
local lsp = {} local lsp = {}
local on_attach = function(_, bufnr) local lsp_attach = function(client, buf)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()")
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end 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")
-- Enable completion triggered by <c-x><c-o> local bufopts = { noremap=true, silent=true, buffer=buf }
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
local opts = { noremap=true, silent=true } vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workleader_folder()<CR>', opts)
buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workleader_folder()<CR>', opts)
buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workleader_folders()))<CR>', opts)
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end end
function lsp.init() function lsp.init()
local lsp_installer = require'nvim-lsp-installer' require'mason'.setup()
require'mason-lspconfig'.setup()
lsp_installer.on_server_ready(function(server) local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local opts = {} local lspconfig = require'lspconfig'
if server.name == 'sumneko_lua' then
opts.settings = { lspconfig.sumneko_lua.setup {
Lua = { capabilities = capabilities,
diagnostics = { settings = {
globals = { 'vim' } Lua = {
} diagnostics = {
globals = { 'vim' }
} }
} }
end },
opts.on_attach = on_attach on_attach = lsp_attach
opts.flags = { }
debounce_text_changes = 150, 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
} }
server:setup(opts) })
end)
end end
return lsp return lsp

View File

@ -6,6 +6,10 @@ function theme.initFont()
vim.opt.guifont = 'Source Code Pro for Powerline' vim.opt.guifont = 'Source Code Pro for Powerline'
end end
function theme.lsp_status()
require'fidget'.setup {}
end
function theme.initStatusline() function theme.initStatusline()
require'lualine'.setup { require'lualine'.setup {
options = { options = {
@ -28,6 +32,7 @@ end
function theme.init() function theme.init()
theme.initFont() theme.initFont()
theme.lsp_status()
theme.initStatusline() theme.initStatusline()
theme.initBufferline() theme.initBufferline()
theme.initColorscheme() theme.initColorscheme()

60
lua/settings/tree.lua Normal file
View File

@ -0,0 +1,60 @@
-- Tree
local tree = {}
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 = false,
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
}
}
}
return tree