nvim: lsp, filetypes
This commit is contained in:
parent
87bcfd8574
commit
e0ea1eee5c
8 changed files with 195 additions and 173 deletions
1
dot_config/nvim/after/ftplugin/yaml.vim
Normal file
1
dot_config/nvim/after/ftplugin/yaml.vim
Normal file
|
@ -0,0 +1 @@
|
|||
setlocal tabstop=2 shiftwidth=2
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||
"Lua.completion.autoRequire": false,
|
||||
"Lua.workspace.checkThirdParty": false
|
||||
}
|
3
dot_config/nvim/ftdetect/dotnet.vim
Normal file
3
dot_config/nvim/ftdetect/dotnet.vim
Normal file
|
@ -0,0 +1,3 @@
|
|||
autocmd BufRead,BufNewFile Directory.Build.props set ft=xml
|
||||
autocmd BufRead,BufNewFile Directory.Build.targets set ft=xml
|
||||
autocmd BufRead,BufNewFile *.cake set filetype=cs
|
|
@ -1,5 +0,0 @@
|
|||
autocmd BufRead,BufNewFile *.yml setlocal shiftwidth=2
|
||||
|
||||
"set expandtab
|
||||
"set shiftwidth=2
|
||||
"set softtabstop=2
|
|
@ -11,15 +11,14 @@ if not vim.loop.fs_stat(lazypath) then
|
|||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
vim.g.loaded_netrwPlugin = true
|
||||
|
||||
require('configs.options').setup()
|
||||
require('lazy').setup('configs.packages', {
|
||||
install = { colorscheme = { 'gruvbox' }, },
|
||||
-- rtp = { disabled_plugins = { 'netrwPlugin' } },
|
||||
})
|
||||
require('lazy').setup(
|
||||
'configs.packages',
|
||||
{
|
||||
install = { colorscheme = { 'gruvbox' }, },
|
||||
-- rtp = { disabled_plugins = { 'netrwPlugin' } },
|
||||
}
|
||||
)
|
||||
|
||||
require('configs.misc').setup()
|
||||
require('configs.keys').setup()
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
vim.g.loaded_netrwPlugin = true
|
||||
|
||||
--vim.o.colorcolumn=0
|
||||
vim.o.autoindent = true
|
||||
vim.o.autoread = true
|
||||
|
@ -11,7 +15,7 @@ function M.setup()
|
|||
vim.o.foldcolumn = 'auto:1'
|
||||
vim.o.foldenable = true
|
||||
vim.o.foldmethod = 'marker'
|
||||
vim.o.foldopen = 'hor,mark,percent,quickfix,search,tag,undo'
|
||||
vim.o.foldopen = 'hor,mark,percent,quickfix,search,tag,undo' -- removed block so { and friends don't open fold
|
||||
vim.o.hidden = true
|
||||
vim.o.ignorecase = true
|
||||
vim.o.inccommand = 'split'
|
||||
|
@ -26,7 +30,7 @@ function M.setup()
|
|||
vim.o.shiftwidth = 4
|
||||
vim.o.showcmd = true
|
||||
vim.o.sidescrolloff = 5
|
||||
vim.o.signcolumn = 'yes'
|
||||
vim.o.signcolumn = 'auto'
|
||||
vim.o.smartcase = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.softtabstop = 4
|
||||
|
|
|
@ -5,7 +5,7 @@ local M = {
|
|||
'b0o/schemastore.nvim',
|
||||
'SmiteshP/nvim-navic',
|
||||
{ 'j-hui/fidget.nvim', config = true },
|
||||
'ray-x/lsp_signature.nvim',
|
||||
{ 'ray-x/lsp_signature.nvim', opts = { hint_prefix = '', floating_window = false, } },
|
||||
'hrsh7th/nvim-cmp',
|
||||
},
|
||||
keys = {
|
||||
|
@ -15,83 +15,83 @@ local M = {
|
|||
lazy = false
|
||||
}
|
||||
|
||||
local function formatting_filter(c)
|
||||
local bl = {
|
||||
'phpactor'
|
||||
}
|
||||
for _, name in ipairs(bl) do
|
||||
if c.name == name then
|
||||
return false;
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function on_attach(args) -- {{{
|
||||
-- require "lsp_signature".on_attach()
|
||||
-- require'completion'.on_attach()
|
||||
local bufnr = args.buf
|
||||
|
||||
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
|
||||
if (client.server_capabilities.documentSymbolProvider) then
|
||||
require('nvim-navic').attach(client, bufnr)
|
||||
end
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap = true, silent = true, buffer = args.buf }
|
||||
local function mkOpts(desc)
|
||||
return { noremap = true, silent = true, buffer = args.buf, desc = desc }
|
||||
end
|
||||
|
||||
-- use LSP default tagfunc
|
||||
-- if client.server_capabilities.definitionProvider then
|
||||
-- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
-- end
|
||||
|
||||
if client.server_capabilities.declarationProvider then
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, mkOpts('LSP declaration'))
|
||||
end
|
||||
|
||||
if client.supports_method('textDocument/hover') and client.name ~= 'null-ls' then
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, mkOpts('LSP hover'))
|
||||
end
|
||||
|
||||
if client.server_capabilities.implementationProvider then
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, mkOpts('LSP implementation'))
|
||||
end
|
||||
|
||||
if client.server_capabilities.signatureHelpProvider then
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, mkOpts('LSP signature help'))
|
||||
vim.keymap.set('i', '<C-k>', vim.lsp.buf.signature_help, mkOpts('LSP signature help'))
|
||||
end
|
||||
|
||||
if client.server_capabilities.codeLensProvider then
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ 'BufEnter', 'CursorHold', 'InsertLeave' }, {
|
||||
callback = vim.lsp.codelens.refresh,
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.keymap.set('n', '<space>cl', vim.lsp.codelens.run, mkOpts('LSP Run code lens'))
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, mkOpts('LSP type definition'))
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, mkOpts('LSP rename'))
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, mkOpts('LSP Code action'))
|
||||
vim.keymap.set('v', '<space>ca', vim.lsp.buf.code_action, mkOpts('LSP Code action'))
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, mkOpts('LSP references'))
|
||||
vim.keymap.set('n', 'gr', '<Cmd>Trouble lsp_references<CR>', mkOpts('LSP references'))
|
||||
|
||||
vim.keymap.set('n', '<space>F', function() vim.lsp.buf.format({ async = true, filter = formatting_filter, }) end,
|
||||
opts)
|
||||
if (formatting_filter(client)) then
|
||||
vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')
|
||||
end
|
||||
end -- }}}
|
||||
|
||||
function M.config()
|
||||
require('neodev').setup({})
|
||||
local formatting_filter = function(c)
|
||||
local bl = {
|
||||
'phpactor'
|
||||
}
|
||||
for _, name in ipairs(bl) do
|
||||
if c.name == name then
|
||||
return false;
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local function on_attach(args)
|
||||
-- require "lsp_signature".on_attach()
|
||||
-- require'completion'.on_attach()
|
||||
local bufnr = args.buf
|
||||
|
||||
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
|
||||
if (client.server_capabilities.documentSymbolProvider) then
|
||||
require('nvim-navic').attach(client, bufnr)
|
||||
end
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap = true, silent = true, buffer = args.buf }
|
||||
local mkOpts = function(desc)
|
||||
return { noremap = true, silent = true, buffer = args.buf, desc = desc }
|
||||
end
|
||||
|
||||
-- use LSP default tagfunc
|
||||
-- if client.server_capabilities.definitionProvider then
|
||||
-- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
-- end
|
||||
|
||||
if client.server_capabilities.declarationProvider then
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, mkOpts('LSP declaration'))
|
||||
end
|
||||
|
||||
if client.supports_method('textDocument/hover') and client.name ~= 'null-ls' then
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, mkOpts('LSP hover'))
|
||||
end
|
||||
|
||||
if client.server_capabilities.implementationProvider then
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, mkOpts('LSP implementation'))
|
||||
end
|
||||
|
||||
if client.server_capabilities.signatureHelpProvider then
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, mkOpts('LSP signature help'))
|
||||
vim.keymap.set('i', '<C-k>', vim.lsp.buf.signature_help, mkOpts('LSP signature help'))
|
||||
end
|
||||
|
||||
if client.server_capabilities.codeLensProvider then
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ 'BufEnter', 'CursorHold', 'InsertLeave' }, {
|
||||
callback = vim.lsp.codelens.refresh,
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.keymap.set('n', '<space>cl', vim.lsp.codelens.run, mkOpts('LSP Run code lens'))
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, mkOpts('LSP type definition'))
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, mkOpts('LSP rename'))
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, mkOpts('LSP Code action'))
|
||||
vim.keymap.set('v', '<space>ca', vim.lsp.buf.code_action, mkOpts('LSP Code action'))
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, mkOpts('LSP references'))
|
||||
vim.keymap.set('n', 'gr', '<Cmd>Trouble lsp_references<CR>', mkOpts('LSP references'))
|
||||
|
||||
vim.keymap.set('n', '<space>F', function() vim.lsp.buf.format({ async = true, filter = formatting_filter, }) end,
|
||||
opts)
|
||||
if (formatting_filter(client)) then
|
||||
vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = on_attach
|
||||
|
@ -99,90 +99,117 @@ function M.config()
|
|||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
-- Use a loop to conveniently both setup defined servers
|
||||
-- and map buffer local keybindings when the language server attaches
|
||||
local servers = {
|
||||
'phpactor',
|
||||
'gopls',
|
||||
'clangd',
|
||||
'zls',
|
||||
'hls',
|
||||
'tsserver',
|
||||
'sumneko_lua',
|
||||
'perlls',
|
||||
'rust_analyzer',
|
||||
'cssls',
|
||||
'html',
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = M.on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
end
|
||||
powershell_es = { bundle_path = '/home/vladimir/devel/PowerShellEditorServices/module' },
|
||||
gopls = {},
|
||||
clangd = {},
|
||||
zls = {},
|
||||
hls = {},
|
||||
tsserver = {},
|
||||
perlls = {},
|
||||
rust_analyzer = {},
|
||||
cssls = {},
|
||||
html = {},
|
||||
omnisharp = { -- {{{
|
||||
cmd = { '/usr/bin/omnisharp' },
|
||||
-- Enables support for reading code style, naming convention and analyzer
|
||||
-- settings from .editorconfig.
|
||||
enable_editorconfig_support = true,
|
||||
|
||||
require('lspconfig').jsonls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
validate = { enable = true },
|
||||
json = {
|
||||
schemas = require('schemastore').json.schemas {
|
||||
replace = {
|
||||
['openapi.json'] = {
|
||||
description = 'A JSON schema for Open API documentation files',
|
||||
fileMatch = { 'openapi.json', 'openapi.yml', 'openapi.yaml', 'openapi/*.json' },
|
||||
name = 'openapi.json',
|
||||
url = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json',
|
||||
versions = {
|
||||
['3.1'] = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json',
|
||||
['3.0'] = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json',
|
||||
}
|
||||
-- If true, MSBuild project system will only load projects for files that
|
||||
-- were opened in the editor. This setting is useful for big C# codebases
|
||||
-- and allows for faster initialization of code navigation features only
|
||||
-- for projects that are relevant to code that is being edited. With this
|
||||
-- setting enabled OmniSharp may load fewer projects and may thus display
|
||||
-- incomplete reference lists for symbols.
|
||||
enable_ms_build_load_projects_on_demand = false,
|
||||
|
||||
-- Enables support for roslyn analyzers, code fixes and rulesets.
|
||||
enable_roslyn_analyzers = true,
|
||||
|
||||
-- Specifies whether 'using' directives should be grouped and sorted during
|
||||
-- document formatting.
|
||||
organize_imports_on_format = true,
|
||||
|
||||
-- Enables support for showing unimported types and unimported extension
|
||||
-- methods in completion lists. When committed, the appropriate using
|
||||
-- directive will be added at the top of the current file. This option can
|
||||
-- have a negative impact on initial completion responsiveness,
|
||||
-- particularly for the first few completion sessions after opening a
|
||||
-- solution.
|
||||
enable_import_completion = true,
|
||||
|
||||
-- Specifies whether to include preview versions of the .NET SDK when
|
||||
-- determining which version to use for project loading.
|
||||
sdk_include_prereleases = true,
|
||||
|
||||
-- Only run analyzers against open files when 'enableRoslynAnalyzers' is
|
||||
-- true
|
||||
analyze_open_documents_only = false,
|
||||
|
||||
}, -- }}}
|
||||
sumneko_lua = { -- {{{
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
callSnippet = 'Replace',
|
||||
},
|
||||
},
|
||||
},
|
||||
}, -- }}}
|
||||
phpactor = { -- {{{
|
||||
root_dir = function(startpath)
|
||||
local u = require('lspconfig.util')
|
||||
return u.search_ancestors(startpath, function(path)
|
||||
return not string.find(path, '/vendor/') and (
|
||||
u.path.exists(u.path.join(path, 'composer.json'))
|
||||
or u.path.exists(u.path.join(path, 'sharedLibs'))
|
||||
or u.path.exists(u.path.join(path, '.git'))
|
||||
)
|
||||
end)
|
||||
end
|
||||
}, -- }}}
|
||||
yamlls = { -- {{{
|
||||
settings = {
|
||||
validate = { enable = true },
|
||||
json = {
|
||||
schemas = require('schemastore').json.schemas {},
|
||||
},
|
||||
},
|
||||
}, -- }}}
|
||||
jsonls = { -- {{{
|
||||
settings = {
|
||||
validate = { enable = true },
|
||||
json = {
|
||||
schemas = require('schemastore').json.schemas {
|
||||
replace = {
|
||||
['openapi.json'] = {
|
||||
description = 'A JSON schema for Open API documentation files',
|
||||
fileMatch = { 'openapi.json', 'openapi.yml', 'openapi.yaml', 'openapi/*.json' },
|
||||
name = 'openapi.json',
|
||||
url = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json',
|
||||
versions = {
|
||||
['3.1'] = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json',
|
||||
['3.0'] = 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json',
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, -- }}}
|
||||
}
|
||||
|
||||
require('lspconfig').yamlls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
validate = { enable = true },
|
||||
json = {
|
||||
schemas = require('schemastore').json.schemas {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require 'lspconfig'.phpactor.setup {
|
||||
-- on_attach = M.on_attach,
|
||||
capabilities = capabilities,
|
||||
|
||||
root_dir = function(startpath)
|
||||
local u = require('lspconfig.util')
|
||||
return u.search_ancestors(startpath, function(path)
|
||||
return not string.find(path, '/vendor/') and (
|
||||
u.path.exists(u.path.join(path, 'composer.json'))
|
||||
or u.path.exists(u.path.join(path, 'sharedLibs'))
|
||||
or u.path.exists(u.path.join(path, '.git'))
|
||||
)
|
||||
end)
|
||||
end
|
||||
}
|
||||
|
||||
require 'lspconfig'.omnisharp.setup {
|
||||
cmd = { '/usr/bin/omnisharp' },
|
||||
capabilities = capabilities,
|
||||
enable_roslyn_analyzers = true,
|
||||
|
||||
}
|
||||
|
||||
require 'lspconfig'.powershell_es.setup {
|
||||
bundle_path = '/home/vladimir/devel/PowerShellEditorServices/module',
|
||||
capabilities = capabilities,
|
||||
}
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
for name, conf in pairs(servers) do
|
||||
conf.capabilities = capabilities
|
||||
nvim_lsp[name].setup(conf)
|
||||
end
|
||||
|
||||
--[[ local util = require("lspconfig.util")
|
||||
require("lspconfig.configs").coffeesense = {
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
return {
|
||||
'ray-x/lsp_signature.nvim',
|
||||
lazy = true,
|
||||
config = {
|
||||
hint_prefix = '',
|
||||
floating_window = false,
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue