refactor: nvim autoformatter / lsp

This commit is contained in:
max_richter 2022-04-09 19:38:57 +02:00
parent 1c225e141d
commit b5aab4aadb
7 changed files with 25 additions and 60 deletions

View File

@ -166,7 +166,7 @@ if u.has_plugin("cmp") then
cmd("highlight Normal guibg=none") cmd("highlight Normal guibg=none")
cmd("highlight NonText guibg=none") cmd("highlight NonText guibg=none")
require("formatter-conf")
-- Configure nvim-tree -- Configure nvim-tree
g.nvim_tree_special_files = {} g.nvim_tree_special_files = {}
@ -291,7 +291,7 @@ if u.has_plugin("cmp") then
-- LSP Config -- LSP Config
require "lspinstaller-conf" require "lspinstaller-conf"
require "lsp-conf" -- require "lsp-conf"
else else
vim.cmd [[PackerSync]] vim.cmd [[PackerSync]]
end end

View File

@ -26,3 +26,9 @@ augroup SaveManualFolds
au BufWinEnter ?* silent! loadview au BufWinEnter ?* silent! loadview
augroup END augroup END
]] ]]
vim.api.nvim_create_autocmd("BufWritePre",{
callback = function()
vim.lsp.buf.formatting_sync();
end
})

View File

@ -7,7 +7,7 @@ local remap = {noremap = false}
g.mapleader = " " g.mapleader = " "
map("n", "<C-p>", ":Telescope find_files<CR>", options) map("n", "<C-o>", ":Telescope find_files<CR>", options)
map("n", "<C-f>", ":Telescope live_grep<CR>", options) map("n", "<C-f>", ":Telescope live_grep<CR>", options)
map("n", "<Shift>", "za", options) map("n", "<Shift>", "za", options)
@ -30,6 +30,9 @@ map("n", "<C-h>", "<C-w>h", options)
map("n", "<C-j>", "<C-w>j", options) map("n", "<C-j>", "<C-w>j", options)
map("n", "<C-k>", "<C-w>k", options) map("n", "<C-k>", "<C-w>k", options)
map("n", "<C-l>", "<C-w>l", options) map("n", "<C-l>", "<C-w>l", options)
-- Browser like next/previous
map("n", "<A-Left>", ":bprevious<CR>",options);
map("n", "<A-Right>", ":bnext<CR>",options);
map("n", "Y", "yy", options) map("n", "Y", "yy", options)
map("n", "<Leader>k", "{", options) map("n", "<Leader>k", "{", options)
@ -53,6 +56,9 @@ map("n", "<Leader>gdh", ":diffget //2<CR>", options)
-- Find file in NvimTree -- Find file in NvimTree
map("n", "<Leader>f", ":NvimTreeFindFile<CR><c-w>", options) map("n", "<Leader>f", ":NvimTreeFindFile<CR><c-w>", options)
map("n", "<C-->",":vsplit<CR>",options);
map("n", "<C-|>",":split<CR>",options);
-- I aint no weak boy -- I aint no weak boy
map("n", "<Left>", ":echo 'No Left for you'<CR><i><dw>", options) map("n", "<Left>", ":echo 'No Left for you'<CR><i><dw>", options)
map("n", "<Right>", ":echo 'No Right for you'<CR><dw>", options) map("n", "<Right>", ":echo 'No Right for you'<CR><dw>", options)

View File

@ -2,11 +2,6 @@ local lsp = require "lspconfig"
local lsp_status = require("lsp-status") local lsp_status = require("lsp-status")
local ts_utils = require("nvim-lsp-ts-utils") local ts_utils = require("nvim-lsp-ts-utils")
-- function to attach completion when setting up lsp
local function on_attach(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
end
local runtime_path = vim.split(package.path, ";") local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua") table.insert(runtime_path, "lua/?/init.lua")
@ -60,24 +55,6 @@ lsp.grammar_guard.setup(
} }
) )
-- Go Language Server
lsp.gopls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Html Setup
lsp.html.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
filetypes = {"html"}
}
-- Svelte Language Server
lsp.svelte.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Typescript Language Server -- Typescript Language Server
lsp.tsserver.setup( lsp.tsserver.setup(
@ -146,21 +123,8 @@ lsp.tsserver.setup(
} }
) )
-- JSON ls setup
lsp.jsonls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- JSON ls setup
lsp.cssls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Setup diagnostics formaters and linters for non LSP provided files -- Setup diagnostics formaters and linters for non LSP provided files
lsp.diagnosticls.setup { lsp.diagnosticls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities, capabilities = lsp_status.capabilities,
cmd = {"diagnostic-languageserver", "--stdio"}, cmd = {"diagnostic-languageserver", "--stdio"},
filetypes = { filetypes = {
@ -234,15 +198,3 @@ lsp.diagnosticls.setup {
} }
} }
} }
-- Enable diagnostics
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
underline = true,
virtual_text = false,
signs = true,
update_in_insert = true
}
)

View File

@ -1,16 +1,15 @@
local lsp_installer = require("nvim-lsp-installer") local lsp_installer = require("nvim-lsp-installer")
require("lsp-format").setup {}
lsp_installer.on_server_ready( lsp_installer.on_server_ready(
function(server) function(server)
local opts = {} local opts = {
on_attach = require "lsp-format".on_attach
-- (optional) Customize the options passed to the server }
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
-- server:setup(opts) server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
end end
) )

View File

@ -75,7 +75,8 @@ return require("packer").startup(
} }
-- Autoformat -- Autoformat
use "sbdchd/neoformat" -- use "sbdchd/neoformat"
use "lukas-reineke/lsp-format.nvim"
-- use "lukas-reineke/format.nvim" -- use "lukas-reineke/format.nvim"
-- General Popup Window -- General Popup Window

View File

@ -0,0 +1 @@
set selection-clipboard clipboard