From edd82ee7d9793bd069f035f4c68b9725e047bbde Mon Sep 17 00:00:00 2001 From: tiyn Date: Fri, 28 Jul 2023 02:14:52 +0200 Subject: [PATCH] nvim: expanded null ls to markdown and embeded code --- .config/nvim/lua/autocmd.lua | 18 +++--- .config/nvim/lua/loadplugins.lua | 1 + .config/nvim/plugin/nvim-cmp.lua | 108 ++++++++++++++----------------- 3 files changed, 61 insertions(+), 66 deletions(-) diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua index 237f994..87a115b 100644 --- a/.config/nvim/lua/autocmd.lua +++ b/.config/nvim/lua/autocmd.lua @@ -1,3 +1,5 @@ +-- autocmd + -- read files correctly vim.filetype.add({ extension = { @@ -19,7 +21,7 @@ vim.api.nvim_create_autocmd({'BufWritePre'}, command = [[%s/\s\+$//e]], }) --- c +-- settings for filetype: c vim.api.nvim_create_autocmd({'VimLeave'}, {pattern = {'c'}, @@ -31,7 +33,7 @@ vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, command = 'set colorcolumn=80' }) --- java +-- settings for filetype: java vim.api.nvim_create_autocmd({'FileType'}, {pattern = {'java'}, @@ -43,14 +45,14 @@ vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, command = 'set colorcolumn=100' }) --- javascript +-- settings for filetype: javascript vim.api.nvim_create_autocmd({'FileType'}, {pattern = {'javascript'}, command = 'setlocal shiftwidth=2 softtabstop=2', }) --- lua +-- settings for filetype: lua vim.api.nvim_create_autocmd({'FileType'}, {pattern = {'lua'}, @@ -62,7 +64,7 @@ vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, command = 'set colorcolumn=100' }) --- markdown +-- settings for filetype: markdown vim.api.nvim_create_autocmd({'FileType'}, {pattern = {'markdown'}, @@ -79,21 +81,21 @@ vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, command = 'set conceallevel=2' }) --- nim +-- settings for filetype: nim vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, {pattern = {'nim'}, command = 'set colorcolumn=80' }) --- python +-- settings for filetype: python vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, {pattern = {'python'}, command = 'set colorcolumn=80' }) --- tex +-- settings for filetype: tex vim.api.nvim_create_autocmd({'VimLeave'}, {pattern = {'tex'}, diff --git a/.config/nvim/lua/loadplugins.lua b/.config/nvim/lua/loadplugins.lua index 1b03f77..661e528 100644 --- a/.config/nvim/lua/loadplugins.lua +++ b/.config/nvim/lua/loadplugins.lua @@ -56,6 +56,7 @@ return require("packer").startup(function(use) 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', 'jose-elias-alvarez/null-ls.nvim', + 'LostNeophyte/null-ls-embedded', 'nvim-lua/plenary.nvim', 'jay-babu/mason-null-ls.nvim'}} diff --git a/.config/nvim/plugin/nvim-cmp.lua b/.config/nvim/plugin/nvim-cmp.lua index 822104e..311a962 100644 --- a/.config/nvim/plugin/nvim-cmp.lua +++ b/.config/nvim/plugin/nvim-cmp.lua @@ -12,13 +12,24 @@ local null_ls = require("null-ls") null_ls.setup({ sources = { - null_ls.builtins.formatting.autopep8, - null_ls.builtins.formatting.nimpretty, + require("null-ls-embedded").nls_source, + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.mdformat, }, }) +require("null-ls").setup({ + sources = { + require("null-ls-embedded").nls_source.with({ + -- default filetypes: + filetypes = { "markdown" }, + }), + }, +}) + require("mason-null-ls").setup({ - automatic_installation = true + automatic_installation = true, + ensure_installed = {} }) -- Add additional capabilities supported by nvim-cmp @@ -79,67 +90,37 @@ cmp.setup { luasnip = "[SNIP]", }, symbol_map = { - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "ﰠ", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "塞", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "פּ", + Text = "", + Method = "", + Function = "φ", + Constructor = "", + Field = "■", + Variable = "β", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "π", + Struct = "", Event = "", - Operator = "", - TypeParameter = "" + Operator = "", + TypeParameter = "" }, }), }, } require("luasnip.loaders.from_snipmate").lazy_load() - --- local on_attach = function(client, bufnr) --- if client.server_capabilities.documentHighlightProvider then --- vim.cmd [[ --- hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow --- hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow --- hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow --- ]] --- vim.api.nvim_create_augroup('lsp_document_highlight', { --- clear = false --- }) --- vim.api.nvim_clear_autocmds({ --- buffer = bufnr, --- group = 'lsp_document_highlight', --- }) --- vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { --- group = 'lsp_document_highlight', --- buffer = bufnr, --- callback = vim.lsp.buf.document_highlight, --- }) --- vim.api.nvim_create_autocmd('CursorMoved', { --- group = 'lsp_document_highlight', --- buffer = bufnr, --- callback = vim.lsp.buf.clear_references, --- }) --- end --- end --- --- vim.g.cursorhold_updatetime = 100 - -- neovim/nvim-lspconfig local nvim_lsp = require('lspconfig') @@ -163,4 +144,15 @@ require'lspconfig'.jdtls.setup{ debounce_text_changes = 150 }, cmd = { 'jdtls' } - } +} + +require'lspconfig'.lua_ls.setup { + settings = { + Lua = { + runtime = { version = 'LuaJIT' }, + diagnostics = { globals = {'vim'} }, + workspace = { library = vim.api.nvim_get_runtime_file("", true) }, + telemetry = { enable = false }, + }, + }, +}