From df0a108c8bb86ab0d95ee396ed664db9b5a10934 Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Mon, 19 Apr 2021 20:22:00 +0200 Subject: [PATCH] nvim: treesitter goodness --- .config/nvim/lua/dln/lsp-config.lua | 6 +++--- .config/nvim/lua/dln/telescope.lua | 2 -- .config/nvim/lua/dln/treesitter.lua | 33 ++++++++++++++++++++++------- .config/nvim/lua/init.lua | 1 + .config/nvim/lua/plugins.lua | 10 ++++++++- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/.config/nvim/lua/dln/lsp-config.lua b/.config/nvim/lua/dln/lsp-config.lua index be68dc0..2f376ef 100644 --- a/.config/nvim/lua/dln/lsp-config.lua +++ b/.config/nvim/lua/dln/lsp-config.lua @@ -7,7 +7,7 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.diagnostic.on_publish_diagnostics, { update_in_insert = false, - virtual_text = {prefix = "‹❮❰ 🔥" } + virtual_text = {prefix = "‹❮❰ " } } ) vim.fn.sign_define( @@ -29,14 +29,14 @@ vim.fn.sign_define( "LspDiagnosticsSignInformation", { text = "💡", - texthl = "LspDiagnosticsSignInformation" + texthl = "LspDiagnosticsSignInformation", } ) vim.fn.sign_define( "LspDiagnosticsSignHint", { text = "💡", - texthl = "LspDiagnosticsSignHint" + texthl = "LspDiagnosticsSignHint", } ) diff --git a/.config/nvim/lua/dln/telescope.lua b/.config/nvim/lua/dln/telescope.lua index 68d9209..86b0cde 100644 --- a/.config/nvim/lua/dln/telescope.lua +++ b/.config/nvim/lua/dln/telescope.lua @@ -23,8 +23,6 @@ telescope.setup { } } --- TODO: Reduce preview ratio --- Override flex layout local layout_strategies = require("telescope.pickers.layout_strategies") local config = require("telescope.config") diff --git a/.config/nvim/lua/dln/treesitter.lua b/.config/nvim/lua/dln/treesitter.lua index 5d8e5c0..a5dd9c0 100644 --- a/.config/nvim/lua/dln/treesitter.lua +++ b/.config/nvim/lua/dln/treesitter.lua @@ -1,24 +1,41 @@ require("nvim-treesitter.configs").setup { ensure_installed = "maintained", highlight = {enable = true}, + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "ss", + node_incremental = "sq", + scope_incremental = "sd", + node_decremental = "sa", + }, + }, + textobjects = { move = { enable = true, goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer" + ["]]"] = "@function.outer", + ["]m"] = "@class.outer" }, goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer" + ["]["] = "@function.outer", + ["]M"] = "@class.outer" }, goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer" + ["[["] = "@function.outer", + ["[m"] = "@class.outer" }, goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer" + ["[]"] = "@function.outer", + ["[M"] = "@class.outer" } }, select = { diff --git a/.config/nvim/lua/init.lua b/.config/nvim/lua/init.lua index 40ec3fd..35d035d 100644 --- a/.config/nvim/lua/init.lua +++ b/.config/nvim/lua/init.lua @@ -48,6 +48,7 @@ vim.o.sidescrolloff = 5 vim.o.termguicolors = true vim.wo.cursorline = true vim.wo.number = true +vim.o.laststatus = 0 --- Key mappings local map = require("dln.utils").map diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index a334b5e..333a7d3 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -77,6 +77,12 @@ return require('packer').startup(function() map('i', '', 'lua vim.lsp.buf.signature_help()') map('n', '1gd', 'lua vim.lsp.buf.type_definition()') map('n', 'gf', 'lua vim.lsp.buf.formatting()') + map('n', 'rn', 'lua vim.lsp.buf.rename()') + map('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()') + map('n', ']d', 'lua vim.lsp.diagnostic.goto_next()') + map('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') + map('n', 'wr', 'lua vim.lsp.buf.add_workspace_folder()') + map('n', 'wl', 'lua vim.lsp.buf.add_workspace_folder()') end } @@ -91,10 +97,11 @@ return require('packer').startup(function() config = function() require('dln.telescope') local map = require('dln.utils').map - map('n', '', 'lua require("telescope.builtin").buffers()') map('n', 'b', 'lua require("telescope.builtin").buffers()') map('n', 'f', 'lua require("telescope.builtin").oldfiles()') + map('n', '', 'lua require("telescope.builtin").oldfiles()') map('n', 'e', 'lua require("telescope.builtin").git_files()') + map('n', 'g', 'lua require("telescope.builtin").git_status()') map('n', 's', 'lua require("telescope.builtin").lsp_document_symbols()') map('n', 't', 'lua require("telescope.builtin").treesitter()') map('n', '/', 'lua require("telescope.builtin").live_grep()') @@ -111,6 +118,7 @@ return require('packer').startup(function() "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", requires = { + "nvim-treesitter/playground", "nvim-treesitter/nvim-treesitter-textobjects", "windwp/nvim-ts-autotag" },