Add bashls and format using formatter built into lua lsp

This commit is contained in:
Fabian Schmidt 2022-10-18 17:42:03 +02:00
parent a8818ea92a
commit fe9da6af57
8 changed files with 84 additions and 80 deletions

View File

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

View File

@ -3,18 +3,18 @@
local maps = {} 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
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 })
-- Enter normal mode in terminal -- Enter normal mode in terminal
map('t', 'ß<C-N>', '<C-\\><C-N>') map('t', 'ß<C-N>', '<C-\\><C-N>')
end end
@ -33,8 +33,8 @@ end
function maps.moveByRow() function maps.moveByRow()
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided -- 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', 'j', 'v:count == 0 ? \'gj\' : \'j\'', { silent = true, expr = true })
map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', {silent = true, expr = true}) map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', { silent = true, expr = true })
end end
function maps.centeredSearch() function maps.centeredSearch()

View File

@ -1,7 +1,7 @@
-- plugin.lua -- plugin.lua
require "paq" { require 'paq' {
-- Handle itself -- Handle itself
'savq/paq-nvim'; 'savq/paq-nvim';

View File

@ -1,8 +1,8 @@
-- Completion -- Completion
local completion = {} local completion = {}
local cmp = require'cmp' local cmp = require('cmp')
local lspkind = require'lspkind' local lspkind = require('lspkind')
vim.opt.shortmess:append 'c' vim.opt.shortmess:append 'c'

View File

@ -32,16 +32,16 @@ function settings.initMisc()
end end
function settings.initVimWiki() function settings.initVimWiki()
vim.g.vimwiki_list = {{path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md'}} vim.g.vimwiki_list = { { path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md' } }
end end
function settings.init() function settings.init()
settings.initMisc() settings.initMisc()
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.completion')
require'settings.tree' require('settings.tree')
end end
return settings return settings

View File

@ -7,7 +7,7 @@ local lsp_attach = function(client, buf)
vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc") 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") vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc")
local bufopts = { noremap=true, silent=true, buffer=buf } 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.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, 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', 'K', vim.lsp.buf.hover, bufopts)
@ -20,11 +20,11 @@ local lsp_attach = function(client, buf)
end end
function lsp.init() function lsp.init()
require'mason'.setup() require('mason').setup()
require'mason-lspconfig'.setup() require('mason-lspconfig').setup()
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lspconfig = require'lspconfig' local lspconfig = require('lspconfig')
lspconfig.sumneko_lua.setup { lspconfig.sumneko_lua.setup {
capabilities = capabilities, capabilities = capabilities,
@ -56,6 +56,10 @@ function lsp.init()
standalone = false standalone = false
} }
}) })
lspconfig.bashls.setup {
capabilities = capabilities,
on_attach = lsp_attach
}
end end
return lsp return lsp

View File

@ -7,11 +7,11 @@ function theme.initFont()
end end
function theme.lsp_status() function theme.lsp_status()
require'fidget'.setup {} require('fidget').setup {}
end end
function theme.initStatusline() function theme.initStatusline()
require'lualine'.setup { require('lualine').setup {
options = { options = {
theme = 'onedark' theme = 'onedark'
} }
@ -19,14 +19,14 @@ function theme.initStatusline()
end end
function theme.initBufferline() function theme.initBufferline()
local bufferline = require'bufferline' local bufferline = require 'bufferline'
bufferline.setup() bufferline.setup()
end end
function theme.initColorscheme() function theme.initColorscheme()
vim.g.limelight_conceal_ctermfg = 'gray' vim.g.limelight_conceal_ctermfg = 'gray'
vim.cmd'colorscheme darcula-solid' vim.cmd 'colorscheme darcula-solid'
vim.cmd'set termguicolors' vim.cmd 'set termguicolors'
vim.opt.syntax = 'on' vim.opt.syntax = 'on'
end end

View File

@ -2,59 +2,59 @@
local tree = {} local tree = {}
require'nvim-tree'.setup { require('nvim-tree').setup {
disable_netrw = true, disable_netrw = true,
hijack_netrw = true, hijack_netrw = true,
open_on_setup = false, open_on_setup = false,
ignore_ft_on_setup = {}, ignore_ft_on_setup = {},
open_on_tab = false, open_on_tab = false,
hijack_cursor = false, hijack_cursor = false,
update_cwd = false, update_cwd = false,
hijack_directories = { hijack_directories = {
enable = true, enable = true,
auto_open = true, auto_open = true,
}, },
diagnostics = { diagnostics = {
enable = false, enable = false,
icons = { icons = {
hint = "", hint = "",
info = "", info = "",
warning = "", warning = "",
error = "", error = "",
} }
}, },
update_focused_file = { update_focused_file = {
enable = false, enable = false,
update_cwd = false, update_cwd = false,
ignore_list = {} ignore_list = {}
}, },
system_open = { system_open = {
cmd = nil, cmd = nil,
args = {} args = {}
}, },
filters = { filters = {
dotfiles = false, dotfiles = false,
custom = {} custom = {}
}, },
git = { git = {
enable = true, enable = true,
ignore = true, ignore = true,
timeout = 500, timeout = 500,
}, },
view = { view = {
width = 30, width = 30,
hide_root_folder = false, hide_root_folder = false,
side = 'left', side = 'left',
mappings = { mappings = {
custom_only = false, custom_only = false,
list = {} list = {}
} }
}, },
actions = { actions = {
open_file = { open_file = {
resize_window = false resize_window = false
}
} }
}
} }
return tree return tree