From fe9da6af5708a3eba62a5e98ca409d98be06d77d Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Tue, 18 Oct 2022 17:42:03 +0200 Subject: [PATCH] Add bashls and format using formatter built into lua lsp --- init.lua | 8 +-- lua/maps.lua | 14 ++--- lua/plugins.lua | 2 +- lua/settings/completion.lua | 4 +- lua/settings/init.lua | 10 ++-- lua/settings/lsp.lua | 12 +++-- lua/settings/theme.lua | 10 ++-- lua/settings/tree.lua | 104 ++++++++++++++++++------------------ 8 files changed, 84 insertions(+), 80 deletions(-) diff --git a/init.lua b/init.lua index 33b3892..0722d4e 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ -- init.lua -require'plugins' -require'settings'.init() -require'maps'.init() -require'commands' +require('plugins') +require('settings').init() +require('maps').init() +require('commands') diff --git a/lua/maps.lua b/lua/maps.lua index f7119cd..ca14bae 100644 --- a/lua/maps.lua +++ b/lua/maps.lua @@ -3,18 +3,18 @@ local maps = {} local function map(mode, lhs, rhs, opts) - local options = {noremap = true} - if opts then options = vim.tbl_extend('force', options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) + local options = { noremap = true } + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) end function maps.toggleGoyo() - map('n', '', ':Goyo', {noremap = false}) + map('n', '', ':Goyo', { noremap = false }) end function maps.term() -- Open and move to resized terminal - map('n', 't', 'sj :terminal:res 5i', {noremap = false}) + map('n', 't', 'sj :terminal:res 5i', { noremap = false }) -- Enter normal mode in terminal map('t', 'ß', '') end @@ -33,8 +33,8 @@ 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}) + 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() diff --git a/lua/plugins.lua b/lua/plugins.lua index 3bbb459..3a31979 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,7 +1,7 @@ -- plugin.lua -require "paq" { +require 'paq' { -- Handle itself 'savq/paq-nvim'; diff --git a/lua/settings/completion.lua b/lua/settings/completion.lua index a610a2d..05b4e99 100644 --- a/lua/settings/completion.lua +++ b/lua/settings/completion.lua @@ -1,8 +1,8 @@ -- Completion local completion = {} -local cmp = require'cmp' -local lspkind = require'lspkind' +local cmp = require('cmp') +local lspkind = require('lspkind') vim.opt.shortmess:append 'c' diff --git a/lua/settings/init.lua b/lua/settings/init.lua index 553d62c..7d7be49 100644 --- a/lua/settings/init.lua +++ b/lua/settings/init.lua @@ -32,16 +32,16 @@ function settings.initMisc() end 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 function settings.init() settings.initMisc() settings.initVimWiki() - require'settings.theme'.init() - require'settings.lsp'.init() - require'settings.completion' - require'settings.tree' + require('settings.theme').init() + require('settings.lsp').init() + require('settings.completion') + require('settings.tree') end return settings diff --git a/lua/settings/lsp.lua b/lua/settings/lsp.lua index 97d21ec..a180610 100644 --- a/lua/settings/lsp.lua +++ b/lua/settings/lsp.lua @@ -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, "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.definition, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) @@ -20,11 +20,11 @@ local lsp_attach = function(client, buf) end function lsp.init() - require'mason'.setup() - require'mason-lspconfig'.setup() + require('mason').setup() + require('mason-lspconfig').setup() 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 { capabilities = capabilities, @@ -56,6 +56,10 @@ function lsp.init() standalone = false } }) + lspconfig.bashls.setup { + capabilities = capabilities, + on_attach = lsp_attach + } end return lsp diff --git a/lua/settings/theme.lua b/lua/settings/theme.lua index c348df1..714147e 100644 --- a/lua/settings/theme.lua +++ b/lua/settings/theme.lua @@ -7,11 +7,11 @@ function theme.initFont() end function theme.lsp_status() - require'fidget'.setup {} + require('fidget').setup {} end function theme.initStatusline() - require'lualine'.setup { + require('lualine').setup { options = { theme = 'onedark' } @@ -19,14 +19,14 @@ function theme.initStatusline() end function theme.initBufferline() - local bufferline = require'bufferline' + local bufferline = require 'bufferline' bufferline.setup() end function theme.initColorscheme() vim.g.limelight_conceal_ctermfg = 'gray' - vim.cmd'colorscheme darcula-solid' - vim.cmd'set termguicolors' + vim.cmd 'colorscheme darcula-solid' + vim.cmd 'set termguicolors' vim.opt.syntax = 'on' end diff --git a/lua/settings/tree.lua b/lua/settings/tree.lua index a107fdd..e65a443 100644 --- a/lua/settings/tree.lua +++ b/lua/settings/tree.lua @@ -2,59 +2,59 @@ 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 +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