all repos

init.lua @ 79766b8

my nvim config
8 files changed, 53 insertions(+), 57 deletions(-)
lsp config update
Author: neoteny ss2316544@gmail.com
Committed at: 2021-11-21 18:41:01 +0200
Parent: ac7bc4d
M lua/keymapings.lua

@@ -43,6 +43,7 @@ nmap("<leader>sp", "<cmd>Telescope projects<cr>")

nmap("<leader>sr", "<cmd>Telescope oldfiles<cr>") nmap("<leader>sb", "<cmd>Telescope git_branches<cr>") nmap("<leader>sc", "<cmd>Telescope git_commits<cr>") +nmap("<leader>sk", "<cmd>Telescope keymaps<cr>") -- DAP nmap("<leader>dt", "<cmd>lua require'dap'.toggle_breakpoint()<cr>")
A lua/lsp/attach.lua

@@ -0,0 +1,26 @@

+return function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + client.resolved_capabilities.document_formatting = false + client.resolved_capabilities.document_range_formatting = false + + local function buf_map(...) + vim.api.nvim_buf_set_keymap(bufnr, "n", ...) + end + + local opts = { noremap = true, silent = true } + buf_map("K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) + buf_map("gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) + buf_map("gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) + buf_map("gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) + buf_map("gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) + buf_map("gs", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) + buf_map("gl", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts) + buf_map("<leader>la", "<cmd>Telescope lsp_code_actions<CR>", opts) + buf_map("<leader>lA", "lua vim.lsp.buf.range_code_action()<CR>", opts) + buf_map("<leader>ld", "<cmd>TroubleToggle<cr>", opts) + buf_map("<leader>lr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) + buf_map("<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) + buf_map("<leader>ls", "<cmd>Telescope lsp_document_symbols<CR>", opts) + buf_map("<leader>li", "<cmd>LspInfo<CR>", opts) + buf_map("<leader>lR", "<cmd>LspRestart<CR>", opts) +end
D

@@ -1,54 +0,0 @@

-local M = {} - -function M.setup() - local on_attach = function(client, bufnr) - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - client.resolved_capabilities.document_formatting = false - client.resolved_capabilities.document_range_formatting = false - - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, "n", ...) - end - - local opts = { noremap = true, silent = true } - buf_set_keymap("K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) - buf_set_keymap("gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) - buf_set_keymap("gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) - buf_set_keymap("gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) - buf_set_keymap("gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) - buf_set_keymap("gs", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) - buf_set_keymap("gl", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts) - buf_set_keymap("<leader>la", "<cmd>Telescope lsp_code_actions<CR>", opts) - buf_set_keymap("<leader>ld", "<cmd>TroubleToggle<cr>", opts) - buf_set_keymap("<leader>lr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) - buf_set_keymap("<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) - buf_set_keymap("<leader>ls", "<cmd>Telescope lsp_document_symbols<CR>", opts) - buf_set_keymap("<leader>li", "<cmd>LspInfo<CR>", opts) - buf_set_keymap("<leader>lR", "<cmd>LspRestart<CR>", opts) - end - - require("nvim-lsp-installer").on_server_ready(function(server) - local opts = { on_attach = on_attach } - - if server.name == "jsonls" then - opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.jsonls" or {}) - elseif server.name == "yamlls" then - opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.yamlls" or {}) - elseif server.name == "tsserver" then - opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.tsserver" or {}) - elseif server.name == "sumneko_lua" then - opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.sumneko_lua" or {}) - elseif server.name == "pyright" then - opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.pyright" or {}) - end - - server:setup(opts) - - require("lsp.null-ls").setup() - require("lspconfig")["null-ls"].setup {} - - vim.cmd [[ do User LspAttachBuffers ]] - end) -end - -return M
A lua/lsp/init.lua

@@ -0,0 +1,22 @@

+local on_attach = require "lsp.attach" +local M = {} + +function M.setup() + require("nvim-lsp-installer").on_server_ready(function(server) + local opts = { on_attach = on_attach } + + local ok, server_opts = pcall(require, "lsp.providers." .. server.name) + if ok then + opts = vim.tbl_deep_extend("force", opts, server_opts or {}) + end + + server:setup(opts) + + vim.cmd [[ do User LspAttachBuffers ]] + + require("lsp.null").setup() + require("lspconfig")["null-ls"].setup {} + end) +end + +return M
M lua/lsp/providers/jsonls.lua

@@ -1,5 +1,8 @@

return { settings = { + schemaDownload = { + enable = true + }, schemas = { { fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" }, },
M lua/plugin.lua

@@ -37,7 +37,7 @@ "williamboman/nvim-lsp-installer",

{ "jose-elias-alvarez/null-ls.nvim", after = "nvim-lspconfig" }, }, config = function() - require("lsp.config").setup() + require("lsp").setup() end, }
M lua/plugin/nvimtree.lua

@@ -37,8 +37,6 @@ },

}, } - vim.g.nvim_tree_gitignore = 1 - vim.g.nvim_tree_root_folder_modifier = ":t" vim.g.nvim_tree_group_empty = 1 vim.g.nvim_tree_indent_markers = 1 end