From 4c036cb741348b3529ead020319baecc4b435160 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Sun, 2 Oct 2022 16:12:53 -0500 Subject: [PATCH] add treesitter-based context and checkbox support --- lua/configs/lspconfig.lua | 6 +++--- lua/configs/treesitter-context.lua | 16 ++++++++++++++++ lua/keybinds.lua | 15 ++++----------- lua/plugins.lua | 8 +++++++- 4 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 lua/configs/treesitter-context.lua diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 32a5e71..3c03389 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -85,10 +85,10 @@ function M.config() lsp_highlight_document(client) end - local sumneko_root_path = '/home/peters/builds/lua-language-server' - local sumneko_binary = sumneko_root_path.."/bin/lua-language-server" + -- local sumneko_root_path = '/home/peters/builds/lua-language-server' + -- local sumneko_binary = sumneko_root_path.."/bin/lua-language-server" lspconfig.sumneko_lua.setup { - cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" }, + -- cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" }, on_attach = on_attach, settings = { Lua = { diff --git a/lua/configs/treesitter-context.lua b/lua/configs/treesitter-context.lua new file mode 100644 index 0000000..c89d3b6 --- /dev/null +++ b/lua/configs/treesitter-context.lua @@ -0,0 +1,16 @@ + +local M = {} + +function M.config() + local present, treesitter_context = pcall(require, 'treesitter-context') + if not present then + return + end + + treesitter_context.setup { + mode = 'topline', + } +end + +return M + diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 4eecaf7..624289f 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -65,15 +65,8 @@ map("n", "", "lua require('lspsaga.action').smart_scroll_with_saga(1)< map("n", "b", "GitBlameToggle", opts) --- LSP (See configs/lsp-installer.lua) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float({ source = true, prefix = function(d, i, ttl) return string.rep(' ', #tostring(ttl) - #tostring(i)) .. tostring(i) .. ': ', nil end })") --- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "go", "lua vim.diagnostic.open_float()", opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", 'lua vim.diagnostic.goto_prev({ border = "rounded" })', opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", 'lua vim.diagnostic.goto_next({ border = "rounded" })', opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "ll", "lua vim.diagnostic.setloclist()", opts) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "lf", "lua vim.lsp.buf.formatting_sync()", opts) +-- LSP (see configs/lsp-installer.lua) +-- Checkboxes (see gerardbm/vim-md-checkbox) +-- nnoremap we :call changecheckbox() +-- nnoremap wx :call deletecheckbox() diff --git a/lua/plugins.lua b/lua/plugins.lua index d64fd37..c95a15b 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -87,6 +87,9 @@ packer.startup { -- Context-based auto commenting use { 'JoosepAlviste/nvim-ts-context-commentstring', after = 'nvim-treesitter' } + -- Show context + use { 'nvim-treesitter/nvim-treesitter-context', config = function() require'configs.treesitter-context'.config() end } + -- -- LSP -- @@ -131,7 +134,7 @@ packer.startup { } -- Snippet Engine (for nvim-cmp) - -- TODO: Add snippets. rafamadriz/friendly-snippets is too cow for me and has too many snippets. + -- TODO: Add snippets? rafamadriz/friendly-snippets is too cow for me and has too many snippets. -- I'd like to use my own collection exclusively (unless there is a better, less extensive collection) use { 'L3MON4D3/LuaSnip' } @@ -162,6 +165,9 @@ packer.startup { -- Formatting for python (:call Black()) use { 'averms/black-nvim', run = ':UpdateRemotePlugins' } + + -- Toggle checkboxes w/ we, delete w/ wx + use { 'gerardbm/vim-md-checkbox' } end, config = { display = {