diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/lua/keymap.lua b/lua/keymap.lua index 5f9bad4..a078510 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -14,18 +14,31 @@ vim.keymap.set("n", "d", tb.man_pages, {}) -- open tree vim.keymap.set({ "i", "n" }, "", vim.cmd.NvimTreeFocus, {}) -- move and copy lines -vim.keymap.set({ "i", "n" }, "", function()vim.api.nvim_feedkeys("ddkP", "x", false)end, {}) -vim.keymap.set({ "i", "n" }, "", function()vim.api.nvim_feedkeys("ddp", "x", false)end, {}) -vim.keymap.set({ "i", "n" }, "", function()vim.api.nvim_feedkeys("yyP", "x", false)end, {}) -vim.keymap.set({ "i", "n" }, "", function()vim.api.nvim_feedkeys("yyp", "x", false)end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("ddkP", "x", false) +end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("ddp", "x", false) +end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("yyP", "x", false) +end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("yyp", "x", false) +end, {}) -- on in normal, insert and start autoComp vim.keymap.set("n", "", function() vim.api.nvim_feedkeys("i", "m", false) local key1 = vim.api.nvim_replace_termcodes("", true, false, true) vim.api.nvim_feedkeys(key1, "m", false) end, {}) +-- toggle function signature +vim.keymap.set("i", "", function() + require("lsp_signature").toggle_float_win() +end, {}) +-- format and vplit remaps vim.keymap.set({ "n", "i" }, "", vim.cmd.Format, {}) vim.keymap.set({ "i", "n" }, "", vim.cmd.vsplit, {}) -- vscode fold and unfold -vim.keymap.set("n", "","zc", {}) +vim.keymap.set("n", "", "zc", {}) vim.keymap.set("n", "", "zo", {}) diff --git a/lua/plugins.lua b/lua/plugins.lua index d3066e1..9ee36ae 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -2,6 +2,9 @@ local plugins = { { "williamboman/mason.nvim", }, + { + "ray-x/lsp_signature.nvim" + }, { "williamboman/mason-lspconfig.nvim", }, diff --git a/lua/setup.lua b/lua/setup.lua index f72e588..ad8a99a 100644 --- a/lua/setup.lua +++ b/lua/setup.lua @@ -16,3 +16,5 @@ require("setuptabout") require("setupufo") require("setupcomment") +-- setup function signature +require("setupsig") diff --git a/lua/setupformat.lua b/lua/setupformat.lua index 495228b..5395c25 100644 --- a/lua/setupformat.lua +++ b/lua/setupformat.lua @@ -2,7 +2,7 @@ -- https://github.com/mhartington/formatter.nvim/tree/master/lua/formatter/filetypes -- Utilities for creating configurations local util = require("formatter.util") - +local defaults = require("formatter.defaults") -- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands require("formatter").setup({ -- Enable or disable logging @@ -13,6 +13,10 @@ require("formatter").setup({ filetype = { -- Formatter configurations for filetype "lua" go here -- and will be executed in order + typescript = { + require("formatter.filetypes.typescript").eslint_d, + util.copyf(defaults.eslint_d), + }, kotlin = { require("formatter.filetypes.kotlin").ktlint, function() diff --git a/lua/setuplsp.lua b/lua/setuplsp.lua index 941c39e..55f621d 100644 --- a/lua/setuplsp.lua +++ b/lua/setuplsp.lua @@ -5,6 +5,12 @@ capabilities.textDocument.foldingRange = { dynamicRegistration = false, lineFoldingOnly = true, } +require("lspconfig").pyright.setup({ + capabilities = capabilities, +}) +require("lspconfig").tsserver.setup({ + capabilities = capabilities, +}) -- require("lspconfig").kotlin_language_server.setup({ capabilities = capabilities, @@ -48,7 +54,7 @@ require("lspconfig").lua_ls.setup({ }) local luasnip = require("luasnip") - +local pairs = require("nvim-autopairs.completion.cmp") local cmp = require("cmp") cmp.setup({ snippet = { @@ -60,7 +66,7 @@ cmp.setup({ -- [''] = cmp.mapping.scroll_docs(-4), -- Up -- [''] = cmp.mapping.scroll_docs(4), -- Down -- C-b (back) C-f (forward) for snippet placeholder navigation. - [''] = cmp.mapping.complete(), + [""] = cmp.mapping.complete(), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, @@ -87,5 +93,7 @@ cmp.setup({ sources = { { name = "nvim_lsp" }, { name = "luasnip" }, + { name = "hrsh7th/cmp-nvim-lsp-signature-help" }, }, }) +cmp.event:on("confirm_done", pairs.on_confirm_done()) diff --git a/lua/setupsig.lua b/lua/setupsig.lua new file mode 100644 index 0000000..ef99df5 --- /dev/null +++ b/lua/setupsig.lua @@ -0,0 +1,4 @@ +local cfg = { + hint_enable = false, +} -- add your config here +require("lsp_signature").setup(cfg)