From b94daf0bd3b1847ef3cb403dcb45fba87b8937a8 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 13 Mar 2022 16:16:19 +0200 Subject: [PATCH] feat: basic folding (should revisit at one point) --- dotfiles/neovim/lua/my/options.lua | 3 ++ dotfiles/neovim/lua/my/options/folding.lua | 15 ++++++++ dotfiles/neovim/lua/my/plugins/lspconfig.lua | 37 ++++++++++---------- dotfiles/neovim/lua/my/plugins/null-ls.lua | 5 ++- 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 dotfiles/neovim/lua/my/options/folding.lua diff --git a/dotfiles/neovim/lua/my/options.lua b/dotfiles/neovim/lua/my/options.lua index fdf771b..ff25353 100644 --- a/dotfiles/neovim/lua/my/options.lua +++ b/dotfiles/neovim/lua/my/options.lua @@ -31,6 +31,9 @@ function M.setup() -- Set leader helpers.global("mapleader", "") + + -- Import other options + require("my.options.folding").setup() end return M diff --git a/dotfiles/neovim/lua/my/options/folding.lua b/dotfiles/neovim/lua/my/options/folding.lua new file mode 100644 index 0000000..0d0fe48 --- /dev/null +++ b/dotfiles/neovim/lua/my/options/folding.lua @@ -0,0 +1,15 @@ +local M = {} + +function M.setup() + vim.o.foldmethod = "marker" + + -- vim.cmd([[ + -- augroup remember_folds + -- autocmd! + -- autocmd BufWinLeave *.* if &ft !=# 'help' | mkview | endif + -- autocmd BufWinEnter *.* if &ft !=# 'help' | silent! loadview | endif + -- augroup END + -- ]]) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/lspconfig.lua b/dotfiles/neovim/lua/my/plugins/lspconfig.lua index a1ea61c..7349d4c 100644 --- a/dotfiles/neovim/lua/my/plugins/lspconfig.lua +++ b/dotfiles/neovim/lua/my/plugins/lspconfig.lua @@ -1,8 +1,5 @@ local M = {} --- Command for formatting lua code -local formatLua = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb" - local function map(buf, mode, lhs, rhs, opts) local options = {noremap = true, silent = true} if opts then options = vim.tbl_extend('force', options, opts) end @@ -32,9 +29,12 @@ function M.on_attach(client, bufnr) map(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()') -- Workspace stuff - map(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') - map(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') - map(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') + map(bufnr, 'n', 'wa', + 'lua vim.lsp.buf.add_workspace_folder()') + map(bufnr, 'n', 'wr', + 'lua vim.lsp.buf.remove_workspace_folder()') + map(bufnr, 'n', 'wl', + 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') -- Code actions map(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()') @@ -77,12 +77,23 @@ local servers = { }, cmd = {"lua-language-server"} }, - purescriptls = {settings = {purescript = {censorWarnings = {"UnusedName", "ShadowedName", "UserDefinedWarning"}, formatter = "purs-tidy"}}}, + purescriptls = { + settings = { + purescript = { + censorWarnings = { + "UnusedName", "ShadowedName", "UserDefinedWarning" + }, + formatter = "purs-tidy" + } + } + }, rnix = {} } function M.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()) -- Setup basic language servers for lsp, details in pairs(servers) do @@ -101,16 +112,6 @@ function M.setup() capabilities = capabilities } end - - -- TODO: replace this with null-ls - local efmLanguages = {lua = {{formatCommand = formatLua, formatStdin = true}}} - - -- Setup auto-formatting - require"lspconfig".efm.setup { - init_options = {documentFormatting = true}, - filetypes = {"lua"}, - settings = {rootMarkers = {".git/"}, languages = efmLanguages} - } end return M diff --git a/dotfiles/neovim/lua/my/plugins/null-ls.lua b/dotfiles/neovim/lua/my/plugins/null-ls.lua index 1534db1..e73518f 100644 --- a/dotfiles/neovim/lua/my/plugins/null-ls.lua +++ b/dotfiles/neovim/lua/my/plugins/null-ls.lua @@ -6,7 +6,10 @@ function M.setup() local null_ls = require("null-ls") local sources = { - null_ls.builtins.formatting.prettierd.with({extra_filetypes = {"markdown"}}) -- format ts files + null_ls.builtins.formatting.prettierd.with({ + extra_filetypes = {"markdown"} + }), -- format ts files + null_ls.builtins.formatting.lua_format -- format lua code } null_ls.setup({sources = sources, on_attach = lspconfig.on_attach})