Pure built-in lsp config finished (probably)

This commit is contained in:
Szwendacz99 2022-10-28 20:55:05 +02:00
parent 647cfeefb2
commit 6105bf7d42
4 changed files with 132 additions and 65 deletions

View file

@ -11,25 +11,23 @@ Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/nvim-cmp'
Plug 'williamboman/mason.nvim' Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim' Plug 'williamboman/mason-lspconfig.nvim'
Plug 'jose-elias-alvarez/null-ls.nvim'
Plug 'mfussenegger/nvim-lint' Plug 'mfussenegger/nvim-lint'
"Plug 'dense-analysis/ale' "Plug 'dense-analysis/ale'
" various plugins " various plugins
Plug 'airblade/vim-gitgutter'
Plug 'akinsho/bufferline.nvim', { 'tag': 'v3.*' } Plug 'akinsho/bufferline.nvim', { 'tag': 'v3.*' }
Plug 'gorbit99/codewindow.nvim' Plug 'gorbit99/codewindow.nvim'
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
Plug 'preservim/nerdcommenter' Plug 'preservim/nerdcommenter'
Plug 'mhinz/vim-startify'
Plug 'rmagatti/auto-session' Plug 'rmagatti/auto-session'
Plug 'tpope/vim-fugitive' Plug 'tpope/vim-fugitive'
Plug 'Glench/Vim-Jinja2-Syntax' Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'vmware-archive/salt-vim' Plug 'vmware-archive/salt-vim'
Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes' Plug 'vim-airline/vim-airline-themes'
Plug 'honza/vim-snippets'
Plug 'itchyny/vim-cursorword' Plug 'itchyny/vim-cursorword'
Plug 'sheerun/vim-polyglot' Plug 'sheerun/vim-polyglot'
Plug 'f-person/git-blame.nvim'
" themes " themes
Plug 'navarasu/onedark.nvim' Plug 'navarasu/onedark.nvim'
@ -53,9 +51,9 @@ call plug#end()
set termguicolors set termguicolors
" load main lua file with additional configs " load main lua file with additional configs
lua require("general")
lua require("my-lspconfig") lua require("my-lspconfig")
lua require("my-lint") lua require("my-lint")
lua require("general")
" highlight all .conf files as apache config (:]) " highlight all .conf files as apache config (:])
autocmd BufEnter *.conf :setlocal filetype=apache autocmd BufEnter *.conf :setlocal filetype=apache
@ -106,6 +104,16 @@ nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr> nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr> nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" gitgutter setup
let g:gitgutter_sign_added = '|'
let g:gitgutter_sign_modified = '|'
let g:gitgutter_sign_removed = '|'
let g:gitgutter_sign_removed_first_line = '|'
let g:gitgutter_sign_removed_above_and_below = '|'
let g:gitgutter_sign_modified_removed = '|'
let g:gitgutter_preview_win_floating = 1
nnoremap <C-g> <cmd>GitGutterPreviewHunk<cr>
" general configs " general configs
set modeline set modeline
let g:sls_use_jinja_syntax = 1 let g:sls_use_jinja_syntax = 1

View file

@ -1,16 +1,27 @@
-- load lsp and dependencies (help for both coc and independent lsp setup) -- load lsp and dependencies
require("mason").setup() require("mason").setup()
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
ensure_installed = { ensure_installed = {
"bashls", "bashls",
"pyright", "pyright",
"pylsp",
--"pyre",
"perlnavigator", "perlnavigator",
"salt_ls", "salt_ls",
"dockerls", "dockerls",
"kotlin_language_server", "kotlin_language_server",
"intelephense", "intelephense",
"phpactor", "eslint",
"eslint" "tsserver",
"markdownlint",
"cssls",
"cssmodules_ls",
"diagnosticls",
"jsonls",
"sumneko_lua",
"sqlls",
"yamlls",
"lemminx"
} }
}) })
@ -28,21 +39,10 @@ codewindow.setup({
codewindow.apply_default_keybinds() codewindow.apply_default_keybinds()
-- Set up nvim-cmp. -- Set up nvim-cmp.
local cmp = require'cmp' local cmp = require'cmp'
cmp.setup({ cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
window = { window = {
-- completion = cmp.config.window.bordered(), -- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(),
@ -92,14 +92,6 @@ cmp.setup.cmdline(':', {
}) })
}) })
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
capabilities = capabilities
}
require'lspconfig'.tsserver.setup{}
require("nvim-tree").setup({ require("nvim-tree").setup({
create_in_closed_folder = true, create_in_closed_folder = true,

View file

@ -1,8 +1,16 @@
require('lint').linters_by_ft = { require('lint').linters_by_ft = {
python = {'flake8', 'pylint', 'pycodestyle',} python = {'flake8', 'pylint', 'pycodestyle', 'pydocstyle',},
php = {'phpcs'},
markdown = {'markdownlint'}
} }
vim.api.nvim_create_autocmd({ "TextChanged" }, { vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})
vim.api.nvim_create_autocmd({ "BufEnter" }, {
callback = function() callback = function()
require("lint").try_lint() require("lint").try_lint()
end, end,

View file

@ -1,7 +1,7 @@
-- setup nvim-lspconfig -- setup nvim-lspconfig
-- Mappings. -- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions -- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true } local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
@ -10,70 +10,129 @@ vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings. -- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr } local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', '<leader>k', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', '<leader>k', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts) vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts) vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function() vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts) end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts) vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end end
local capabilities = require('cmp_nvim_lsp').default_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
require'lspconfig'.pyright.setup{ require 'lspconfig'.pyright.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.bashls.setup{ require 'lspconfig'.pylsp.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.salt_ls.setup{ require 'lspconfig'.pyre.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.dockerls.setup{ require 'lspconfig'.bashls.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.kotlin_language_server.setup{ require 'lspconfig'.salt_ls.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.intelephense.setup{ require 'lspconfig'.dockerls.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.eslint.setup{ require 'lspconfig'.kotlin_language_server.setup {
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require'lspconfig'.perlnavigator.setup{ require 'lspconfig'.intelephense.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.eslint.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.tsserver.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.perlnavigator.setup {
settings = { settings = {
perlnavigator = { perlnavigator = {
perlPath = 'perl', perlPath = 'perl',
enableWarnings = true, enableWarnings = true,
perltidyProfile = '', perltidyProfile = '',
perlcriticProfile = '', perlcriticProfile = '',
perlcriticEnabled = true, perlcriticEnabled = true,
} }
}, },
on_attach = on_attach, on_attach = on_attach,
capabilities = capabilities, capabilities = capabilities,
} }
require 'lspconfig'.cssls.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.cssmodules_ls.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.diagnosticls.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.jsonls.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.sumneko_lua.setup {
on_attach = on_attach,
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { 'vim' },
},
},
},
}
require 'lspconfig'.sqlls.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.yamlls.setup {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.lemminx.setup {
on_attach = on_attach,
capabilities = capabilities,
}