From 4541f0fba0c365af9cfb5bbab145c725b390a70e Mon Sep 17 00:00:00 2001 From: Taken Date: Fri, 29 Sep 2023 20:04:58 +0200 Subject: [PATCH] Moved ts tools to seperate file --- lua/taken/core/on_attach.lua | 35 ++++++++++++++++++ lua/taken/plugins/indent-blankline.lua | 15 +++++--- lua/taken/plugins/lsp/lspconfig.lua | 50 +------------------------- lua/taken/plugins/lsp/ts-tools.lua | 27 ++++++++++++++ 4 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 lua/taken/core/on_attach.lua create mode 100644 lua/taken/plugins/lsp/ts-tools.lua diff --git a/lua/taken/core/on_attach.lua b/lua/taken/core/on_attach.lua new file mode 100644 index 0000000..eca51d7 --- /dev/null +++ b/lua/taken/core/on_attach.lua @@ -0,0 +1,35 @@ +local on_attach = function(client, bufnr) + local opts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("n", "gd", "Telescope lsp_definitions", opts) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gi", "Telescope lsp_implementations", opts) + vim.keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "K", function() + vim.lsp.buf.hover() + end, opts) + vim.keymap.set("n", "vws", function() + vim.lsp.buf.workspace_symbol() + end, opts) + vim.keymap.set("n", "vd", function() + vim.diagnostic.open_float() + end, opts) + vim.keymap.set("n", "[d", function() + vim.diagnostic.goto_next() + end, opts) + vim.keymap.set("n", "]d", function() + vim.diagnostic.goto_prev() + end, opts) + vim.keymap.set("n", "vca", function() + vim.lsp.buf.code_action() + end, opts) + vim.keymap.set("n", "gR", "Telescope lsp_references", opts) + vim.keymap.set("n", "vrn", function() + vim.lsp.buf.rename() + end, opts) + vim.keymap.set("i", "", function() + vim.lsp.buf.signature_help() + end, opts) +end + +return on_attach diff --git a/lua/taken/plugins/indent-blankline.lua b/lua/taken/plugins/indent-blankline.lua index 5b67d49..6969aa4 100644 --- a/lua/taken/plugins/indent-blankline.lua +++ b/lua/taken/plugins/indent-blankline.lua @@ -1,17 +1,22 @@ return { "lukas-reineke/indent-blankline.nvim", + main = "ibl", event = { "BufReadPre", "BufNewFile" }, config = function() - local blankline = require("indent_blankline") + local blankline = require("ibl") vim.opt.list = true vim.opt.listchars:append("space:⋅") blankline.setup({ - show_end_of_line = false, - space_char_blankline = " ", - show_current_context = true, - show_current_context_start = true, + indent = { + char = "│", + highlight = { "Function", "Label" }, + }, + -- show_end_of_line = false, + -- space_char_blankline = " ", + -- show_current_context = true, + -- show_current_context_start = true, }) end, } diff --git a/lua/taken/plugins/lsp/lspconfig.lua b/lua/taken/plugins/lsp/lspconfig.lua index 732bd47..7c66471 100644 --- a/lua/taken/plugins/lsp/lspconfig.lua +++ b/lua/taken/plugins/lsp/lspconfig.lua @@ -3,50 +3,14 @@ return { dependencies = { "hrsh7th/cmp-nvim-lsp", "folke/neodev.nvim", - "pmizio/typescript-tools.nvim", - "nvim-lua/plenary.nvim", }, event = { "BufReadPre", "BufNewFile" }, config = function() local neodev = require("neodev") local lspconfig = require("lspconfig") local cmp_nvim_lsp = require("cmp_nvim_lsp") - local typescript_tools = require("typescript-tools") - - local on_attach = function(client, bufnr) - local opts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("n", "gd", "Telescope lsp_definitions", opts) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("n", "gi", "Telescope lsp_implementations", opts) - vim.keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "K", function() - vim.lsp.buf.hover() - end, opts) - vim.keymap.set("n", "vws", function() - vim.lsp.buf.workspace_symbol() - end, opts) - vim.keymap.set("n", "vd", function() - vim.diagnostic.open_float() - end, opts) - vim.keymap.set("n", "[d", function() - vim.diagnostic.goto_next() - end, opts) - vim.keymap.set("n", "]d", function() - vim.diagnostic.goto_prev() - end, opts) - vim.keymap.set("n", "vca", function() - vim.lsp.buf.code_action() - end, opts) - vim.keymap.set("n", "gR", "Telescope lsp_references", opts) - vim.keymap.set("n", "vrn", function() - vim.lsp.buf.rename() - end, opts) - vim.keymap.set("i", "", function() - vim.lsp.buf.signature_help() - end, opts) - end + local on_attach = require("taken.core.on_attach") local capabilities = cmp_nvim_lsp.default_capabilities() local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " } @@ -72,18 +36,6 @@ return { }, }) - typescript_tools.setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = { - tsserver_file_preferences = { - includeInlayParameterNameHints = "all", - includeCompletionsForModuleExports = true, - quotePreference = "auto", - }, - }, - }) - lspconfig["html"].setup({ capabilities = capabilities, on_attach = on_attach, diff --git a/lua/taken/plugins/lsp/ts-tools.lua b/lua/taken/plugins/lsp/ts-tools.lua new file mode 100644 index 0000000..8d8206b --- /dev/null +++ b/lua/taken/plugins/lsp/ts-tools.lua @@ -0,0 +1,27 @@ +return { + "pmizio/typescript-tools.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "neovim/nvim-lspconfig", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + local typescript_tools = require("typescript-tools") + local cmp_nvim_lsp = require("cmp_nvim_lsp") + + local on_attach = require("taken.core.on_attach") + local capabilities = cmp_nvim_lsp.default_capabilities() + + typescript_tools.setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { + tsserver_file_preferences = { + includeInlayParameterNameHints = "all", + includeCompletionsForModuleExports = true, + quotePreference = "auto", + }, + }, + }) + end, +}