Add nvim config

This commit is contained in:
Thomas Avé 2022-07-02 14:37:50 +02:00
parent 1b98f91de9
commit f557c593f9
15 changed files with 656 additions and 308 deletions

308
.nvimrc
View File

@ -1,308 +0,0 @@
set nocompatible
syntax on
let VIMHOME = split(&rtp, ",")[0]
let $VIMHOME = VIMHOME
" vim-plug
call plug#begin(VIMHOME."/plugs")
" Plug 'Valloric/YouCompleteMe'
Plug 'williamboman/nvim-lsp-installer'
Plug 'nixprime/cpsm', {'do': './install.sh'}
Plug 'kien/ctrlp.vim'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'NLKNguyen/papercolor-theme'
Plug 'Shougo/deoplete.nvim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'cohama/lexima.vim', {'do': 'sed -i \"s/has(.nvim.) && //\" autoload/lexima/insmode.vim'}
Plug 'editorconfig/editorconfig-vim'
Plug 'gmarik/Vundle.vim'
Plug 'hdima/python-syntax'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'kristijanhusak/vim-hybrid-material'
Plug 'lambdalisue/fern.vim'
Plug 'lervag/vimtex'
Plug 'neovimhaskell/haskell-vim'
Plug 'nvie/vim-flake8'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'pangloss/vim-javascript'
Plug 'posva/vim-vue'
Plug 'rhysd/vim-grammarous'
Plug 'roxma/nvim-yarp'
Plug 'ervandew/supertab'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'tmux-plugins/vim-tmux'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'tomtom/tcomment_vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-scripts/indentpython.vim'
Plug 'vimwiki/vimwiki'
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
call plug#end()
let mapleader=","
:command W w
:command Q q
:command WQ wq
:command Wq wq
nnoremap j gj
nnoremap k gk
nnoremap <C-U> <C-O>
nnoremap <C-E> <C-U>
" don't store .swp files in the file's own directory
" neither for .ext~ files
set directory=/home/user/.nvim/tmp/
set backupdir=/home/user/.nvim/tmp/
" VimWiki
let g:vimwiki_key_mappings = { 'table_mappings': 0 }
let g:vimwiki_markdown_link_ext = 1
autocmd FileType vimwiki setlocal shiftwidth=2 softtabstop=2 expandtab
" Autoindent for filetype
filetype plugin indent on
set autoindent
set encoding=utf-8
set scrolloff=5
set sidescrolloff=10
set completeopt-=preview
set backspace=indent,eol,start
" Splits
set splitbelow
set splitright
" CtrlP
let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'}
nnoremap <silent> <C-o> :CtrlPBuffer<CR>
let g:cpsm_unicode=1
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Unsaved buffer switching
set hidden
" Line numbering
set number
set numberwidth=4
:set mouse=a
" Allow xterm-key usage inside tmux
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
" Persistent undo
set undodir=~/.nvim/undodir/
set undofile
set undolevels=1000
set undoreload=10000
" Searching
set ignorecase
set smartcase
set incsearch
set hlsearch
nnoremap <leader><space> :noh<CR>
" Text wrapping
set lbr
" Vimtex
let g:tex_flavor = 'latex'
" Tabs
if has("autocmd")
filetype plugin indent on
autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab
endif
" Terminal colors
set t_Co=256
set background=dark
let g:airline_theme="solarized"
let g:airline_solarized_bg="dark"
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" Commenting
nnoremap <silent> <leader>c :TComment<CR>
nnoremap <silent> <leader>C :TCommentBlock<CR>
vnoremap <silent> <leader>c :TCommentInline<CR>
vnoremap <silent> <leader>C :TCommentBlock<CR>
" Tab completion
set wildmode=longest,list
set wildmenu
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ 13
let g:airline_powerline_fonts = 1
set laststatus=2
set ttimeoutlen=50
" Color scheme
syntax enable
let python_highlight_all=1
let g:solarized_termcolors=256
colorscheme hybrid_material
" Remap u to y
vnoremap u y
" Save clipboard on quit
autocmd VimLeave * call system("xsel -ib", getreg('+'))
" Automatically remove trailing spaces
let blacklist = ['vimwiki']
autocmd BufWritePre * if index(blacklist, &ft) < 0 | :%s/\s\+$//e
" Use deoplete.
autocmd FileType python let g:deoplete#enable_at_startup = 1
" VPW: set filetype for .py3
autocmd BufRead,BufNewFile *.py3 set filetype=python
" Vue indent
autocmd FileType vue setlocal shiftwidth=2 softtabstop=2 expandtab
autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 expandtab
autocmd FileType vue syntax sync fromstart
" Disable shift+k for manual lookup
map <S-k> <Nop>
" Prolog: set filetype for .pl
autocmd BufRead,BufNewFile *.pl set filetype=prolog
" Disable modelines, fix CVE
set modelines=0
set nomodeline
" Tab for completion
let g:SuperTabContextDefaultCompletionType = "<c-n>"
let g:SuperTabDefaultCompletionType = "<c-n>"
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
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 = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s"}),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require("nvim-lsp-installer").setup({
automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig)
})
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['pyright'].setup {
capabilities = capabilities
}
require('lspconfig')['texlab'].setup {
capabilities = capabilities
}
require('lspconfig')['ltex'].setup {
capabilities = capabilities
}
EOF
" Lanuage server
nnoremap <silent> <buffer> gd :lua vim.lsp.buf.definition()<CR>
set updatetime=300
set signcolumn=number
nmap <silent> <leader>n :lua vim.lsp.diagnostic.goto_next()<CR>
nmap <silent> <leader>p :lua vim.lsp.diagnostic.goto_prev()<CR>
nmap <silent> <leader>f :lua vim.lsp.buf.code_action()<CR>

148
nvim/init.vim Normal file
View File

@ -0,0 +1,148 @@
" vim-plug
call plug#begin()
Plug 'williamboman/nvim-lsp-installer'
Plug 'nixprime/cpsm', {'do': './install.sh'}
Plug 'kien/ctrlp.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'christoomey/vim-tmux-navigator'
Plug 'cohama/lexima.vim', {'do': 'sed -i \"s/has(.nvim.) && //\" autoload/lexima/insmode.vim'}
Plug 'editorconfig/editorconfig-vim'
Plug 'kristijanhusak/vim-hybrid-material'
Plug 'lervag/vimtex'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'pangloss/vim-javascript'
Plug 'posva/vim-vue'
Plug 'ervandew/supertab'
Plug 'tmux-plugins/vim-tmux'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'tomtom/tcomment_vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vimwiki/vimwiki'
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
call plug#end()
:lua require('lsp_config')
set autoindent
set background=dark
set backspace=indent,eol,start
set completeopt-=preview
set encoding=utf-8
set expandtab
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ 13
set hidden
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set lbr
set modelines=0
set mouse=a
set nocompatible
set nomodeline
set number
set numberwidth=4
set scrolloff=5
set shiftwidth=4
set sidescrolloff=10
set smartcase
set softtabstop=4
set splitbelow
set splitright
set t_Co=256
set tabstop=4
set ttimeoutlen=50
set undofile
set undolevels=1000
set undoreload=10000
set wildmenu
set wildmode=longest,list
:command W w
:command Q q
:command WQ wq
:command Wq wq
nnoremap j gj
nnoremap k gk
vnoremap u y
nnoremap <C-U> <C-O>
nnoremap <C-E> <C-U>
nnoremap <leader><space> :noh<CR>
let python_highlight_all=1
let g:solarized_termcolors=256
let g:airline_powerline_fonts = 1
let mapleader=","
colorscheme hybrid_material
syntax enable
filetype plugin indent on
autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab
" VimWiki
let g:vimwiki_key_mappings = { 'table_mappings': 0 }
let g:vimwiki_markdown_link_ext = 1
autocmd FileType vimwiki setlocal shiftwidth=2 softtabstop=2 expandtab
" CtrlP
let g:ctrlp_match_func = {'match': 'cpsm#CtrlPMatch'}
nnoremap <silent> <C-o> :CtrlPBuffer<CR>
let g:cpsm_unicode=1
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Allow xterm-key usage inside tmux
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
" Airline
let g:airline_theme="solarized"
let g:airline_solarized_bg="dark"
" Vimtex
let g:tex_flavor = 'latex'
" Commenting
nnoremap <silent> <leader>c :TComment<CR>
nnoremap <silent> <leader>C :TCommentBlock<CR>
vnoremap <silent> <leader>c :TCommentInline<CR>
vnoremap <silent> <leader>C :TCommentBlock<CR>
" Automatically remove trailing spaces
let blacklist = ['vimwiki']
autocmd BufWritePre * if index(blacklist, &ft) < 0 | :%s/\s\+$//e
" Disable shift+k for manual lookup
map <S-k> <Nop>
" Prolog: set filetype for .pl
autocmd BufRead,BufNewFile *.pl set filetype=prolog
" Tab for completion
let g:SuperTabContextDefaultCompletionType = "<c-n>"
let g:SuperTabDefaultCompletionType = "<c-n>"
" Lanuage server
nnoremap <silent> <buffer> gd :lua vim.lsp.buf.definition()<CR>
set updatetime=300
set signcolumn=number
nmap <silent> <leader>n :lua vim.lsp.diagnostic.goto_next()<CR>
nmap <silent> <leader>p :lua vim.lsp.diagnostic.goto_prev()<CR>
nmap <silent> <leader>f :lua vim.lsp.buf.code_action()<CR>

113
nvim/lua/lsp_config.lua Normal file
View File

@ -0,0 +1,113 @@
-- Setup nvim-cmp.
local cmp = require'cmp'
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 = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s"}),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require("nvim-lsp-installer").setup({
automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig)
})
require('lspconfig').pyright.setup {
capabilities = capabilities
}
require('lspconfig').texlab.setup {
capabilities = capabilities
}
require('lspconfig').ltex.setup {
capabilities = capabilities,
on_attach = function(client, bufnr)
require("ltex_extra").setup{
load_langs = {"nl-BE", "en-US"},
init_check = true,
}
end,
settings = {
ltex = {
enabled = {"latex", "tex", "bib", "md"},
language="en-GB",
}
}
}
vim.diagnostic.config({
virtual_text = false
})
-- Show line diagnostics automatically in hover window
vim.o.updatetime = 250
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]

View File

@ -0,0 +1,49 @@
local log = require("ltex_extra.src.log")
local M = {}
local default_opts = {
load_langs = { "es-AR", "en-US" },
init_check = true,
}
M.opts = {}
M.setup = function(opts)
log.trace("Merge options")
M.opts = opts or default_opts
for key, value in pairs(default_opts) do
if not M.opts[key] then
M.opts[key] = value
end
end
log.trace("Add commands to lsp")
vim.lsp.commands['_ltex.addToDictionary'] = require("ltex_extra.src.commands-lsp").addToDictionary
vim.lsp.commands['_ltex.hideFalsePositives'] = require("ltex_extra.src.commands-lsp").hideFalsePositives
vim.lsp.commands['_ltex.disableRules'] = require("ltex_extra.src.commands-lsp").disableRules
log.trace("Inital load files")
if opts.init_check == true then
require("ltex_extra.src.commands-lsp").updateConfigFull(opts.load_langs)
end
end
return M
-- Dev notes:
--
-- Dummy functions for test vim.lsp.commands
-- local dummy_calls = 0
-- local dummy_cmd = function()
-- print(dummy_calls)
-- dummy_calls = dummy_calls + 1
-- print(dummy_calls)
-- end
-- Inspect function for arguments. Doesn't work after nvim 0.7.
-- local orig_execute_command = vim.lsp.buf.execute_command
-- vim.lsp.buf.execute_command = function (command)
-- print(vim.inspect(command))
-- orig_execute_command(command)
-- end

View File

@ -0,0 +1,116 @@
local log = require("ltex_extra.src.log")
local inspect = require("ltex_extra.src.utils").inspect
local writeFile = require("ltex_extra.src.utils").writeFile
local loadFile = require("ltex_extra.src.utils").readFile
local types = {
["dict"] = "dictionary",
["dRules"] = "disabledRules",
["hRules"] = "hiddenFalsePositives"
}
local function catch_ltex()
log.trace("catch_ltex")
local buf_clients = vim.lsp.buf_get_clients()
local client = nil
for _, lsp in ipairs(buf_clients) do
if lsp.name == "ltex" then client = lsp end
end
return client
end
local function update_dictionary(client, lang)
log.trace("update_dictionary")
if not client.config.settings.ltex.dictionary then
client.config.settings.ltex.dictionary = {}
end
client.config.settings.ltex.dictionary[lang] = loadFile(types.dict, lang)
log.debug(inspect(client.config.settings.ltex.dictionary))
return client.notify('workspace/didChangeConfiguration', client.config.settings)
end
local function update_disabledRules(client, lang)
log.trace("update_disabledRules")
if not client.config.settings.ltex.disabledRules then
client.config.settings.ltex.disabledRules = {}
end
client.config.settings.ltex.disabledRules[lang] = loadFile(types.dRules, lang)
log.debug(inspect(client.config.settings.ltex.disabledRules))
return client.notify('workspace/didChangeConfiguration', client.config.settings)
end
local function update_hiddenFalsePositive(client, lang)
log.trace("update_hiddenFalsePositive")
if not client.config.settings.ltex.hiddenFalsePositives then
client.config.settings.ltex.hiddenFalsePositives = {}
end
client.config.settings.ltex.hiddenFalsePositives[lang] = loadFile(types.hRules, lang)
log.debug(inspect(client.config.settings.ltex.hiddenFalsePositives))
return client.notify('workspace/didChangeConfiguration', client.config.settings)
end
local M = {}
M.updateConfig = function(configtype, lang)
log.trace("updateConfig")
local client = catch_ltex()
if client then
if configtype == types.dict then
update_dictionary(client, lang)
elseif configtype == types.dRules then
update_disabledRules(client, lang)
elseif configtype == types.hRules then
update_hiddenFalsePositive(client, lang)
else
log.fmt_error("Config type unknown")
return vim.notify("Config type unknown")
end
else
log.fmt_error("Error catching ltex client")
return vim.notify("Error catching ltex client")
end
end
M.updateConfigFull = function(langs)
log.trace("updateConfigFull")
langs = langs or package.loaded.ltex_extra.opts.load_langs
for _, lang in pairs(langs) do
log.fmt_trace("Loading %s", lang)
M.updateConfig(types.dict, lang)
M.updateConfig(types.dRules, lang)
M.updateConfig(types.hRules, lang)
end
end
M.addToDictionary = function(command)
log.trace("addToDictionary")
local args = command.arguments[1].words
for lang, words in pairs(args) do
log.fmt_debug("Lang: %s Words: %s", inspect(lang), inspect(words))
writeFile(types.dict, lang, words)
M.updateConfig(types.dict, lang)
end
end
M.disableRules = function(command)
log.trace("disableRules")
local args = command.arguments[1].ruleIds
for lang, rules in pairs(args) do
log.fmt_debug("Lang: %s Rules: %s", inspect(lang), inspect(rules))
writeFile(types.dRules, lang, rules)
M.updateConfig(types.dRules, lang)
end
end
M.hideFalsePositives = function(command)
log.trace("hideFalsePositives")
local args = command.arguments[1].falsePositives
for lang, rules in pairs(args) do
log.fmt_debug("Lang: %s Rules: %s", inspect(lang), inspect(rules))
writeFile(types.hRules, lang, rules)
M.updateConfig(types.hRules, lang)
end
end
return M

View File

@ -0,0 +1,62 @@
local debug = false
local log = {}
if debug then
log = require("plenary.log").new {
plugin = "ltex_extra",
use_file = false,
level = "trace"
}
else
local dummy = function (...) return true end
log.trace = dummy
log.debug = dummy
log.info = dummy
log.warn = dummy
log.error = dummy
log.fatal = dummy
log.fmt_trace = dummy
log.fmt_debug = dummy
log.fmt_info = dummy
log.fmt_warn = dummy
log.fmt_error = dummy
log.fmt_fatal = dummy
end
-- local default_config = {
-- -- Name of the plugin. Prepended to log messages
-- plugin = "plenary",
--
-- -- Should print the output to neovim while running
-- -- values: 'sync','async',false
-- use_console = "async",
--
-- -- Should highlighting be used in console (using echohl)
-- highlights = true,
--
-- -- Should write to a file
-- use_file = true,
--
-- -- Should write to the quickfix list
-- use_quickfix = false,
--
-- -- Any messages above this level will be logged.
-- level = p_debug and "debug" or "info",
--
-- -- Level configuration
-- modes = {
-- { name = "trace", hl = "Comment" },
-- { name = "debug", hl = "Comment" },
-- { name = "info", hl = "None" },
-- { name = "warn", hl = "WarningMsg" },
-- { name = "error", hl = "ErrorMsg" },
-- { name = "fatal", hl = "ErrorMsg" },
-- },
--
-- -- Can limit the number of decimals displayed for floats
-- float_precision = 0.01,
-- }
return log

View File

@ -0,0 +1,54 @@
local M = {}
-- PRIVATE FUNCTIONS
M.file_exists = function(filename)
local file = io.open(filename, "r")
if file ~= nil then io.close(file) return true else return false end
end
-- PUBLIC FUNCTIONS
M.writeFile = function(type, lang, lines)
local filename = table.concat({ "ltex", type, lang, "txt" }, ".")
local file = io.open(filename, "a+")
io.output(file)
for _, line in ipairs(lines) do
io.write(line .. "\n")
end
io.close(file)
end
M.readFile = function(type, lang)
local filename = table.concat({ "ltex", type, lang, "txt" }, ".")
local lines = {}
if M.file_exists(filename) then
local file = io.open(filename, "r")
io.input(file)
for line in io.lines(filename) do
lines[#lines + 1] = line
end
io.close(file)
end
return lines
end
M.loadFile = function(type, langs)
local content = {}
for _, lang in ipairs(langs) do
content[lang] = M.readFile(type, lang)
end
return content
end
M.inspect = function(args)
local inspect = nil
if vim then
inspect = vim.inspect
else
inspect = require("inspect") -- from luarocks
end
return inspect(args)
end
return M

View File

@ -0,0 +1,41 @@
local inspect = require("inspect")
local lnsep = "=========="
local function println(arg) print("\n" .. lnsep .. arg .. lnsep) end
local commands = require("test.commands")
local addToDictionary = require("src.commands-lsp").addToDictionary
local disableRules = require("src.commands-lsp").disableRules
local hideFalsePositives = require("src.commands-lsp").hideFalsePositives
local inspect = require("src.utils").inspect
local writeFile = require("src.utils").writeFile
local readFile = require("src.utils").readFile
local load_file = require("src.utils").load_file
local langs = {"es-AR", "en-US"}
-- Command Handler mockup.
local function execute_command(command)
println(command.command)
print("command = " .. inspect(command))
if command.command == '_ltex.addToDictionary' then
addToDictionary(commands.dictionary)
elseif command.command == '_ltex.disableRules' then
disableRules(commands.disableRules)
elseif command.command == '_ltex.hideFalsePositives' then
hideFalsePositives(commands.hideFalsePositives)
end
end
execute_command(commands.dictionary)
execute_command(commands.disableRules)
execute_command(commands.hideFalsePositives)
println("Reading file")
local dictionary = load_file("dictionary", langs)
local disabledRules = load_file("disabledRules", langs)
local hiddenFalsePositives = load_file("hiddenFalsePositives", langs)
print(inspect({dictionary, disabledRules, hiddenFalsePositives}))
-- local dictionary_example = {["es-AR"] = {"Errorr"}, ["en-US"] = {"Errorr"}}
-- print(M.inspect(dictionary_example))

View File

@ -0,0 +1,38 @@
-- Commands captured from LSP Code action.
local commands = {}
commands.dictionary = {
arguments = { {
uri = "file:///home/leonardo/.config/nvim/lua/test/latex/main.tex",
words = {
["en-US"] = { "Error", "Warning" },
}
} },
command = "_ltex.addToDictionary",
title = "Add 'Errorr' to dictionary"
}
commands.disableRules = {
arguments = { {
ruleIds = {
["en-US"] = { "MORFOLOGIK_RULE_ES", "INCORRECT_SPACES" }
},
uri = "file:///home/leonardo/develop/ltex-lua/readme.md"
} },
command = "_ltex.disableRules",
title = "Disable rule"
}
commands.hideFalsePositives = {
arguments = { {
falsePositives = {
["en-US"] = { '{"rule":"UPPERCASE_SENTENCE_START","sentence":"^\\\\Qerror with false positive.\\\\E$"}',
'{"rule":"UPPERCASE_SENTENCE_START","sentence":"^\\\\Qerror with false positive.\\\\E$"}' }
},
uri = "file:///home/leonardo/develop/ltex-lua/readme.md"
} },
command = "_ltex.hideFalsePositives",
title = "Hide false positive"
}
return commands

View File

@ -0,0 +1,9 @@
@online{ltex,
author = {Valentjn},
keywords = {ltex},
month = jun,
publisher = {Github},
title = {LTeX language server},
url = {https://valentjn.github.io/ltex/settings.html},
year = {2022}
}

View File

@ -0,0 +1,10 @@
---
lang: es-AR
---
This is a misspelling.
this sentences should beggining uppercase.
This rules is going to be disabled.
Esto es un errorr.
esta oración debe comenzar con mayúsculas.
Esta regla sera desactivada.

View File

@ -0,0 +1,16 @@
\documentclass{article}
% \usepackage[english]{babel}
\usepackage[spanish]{babel}
\begin{document}
This is a missspell.
this sentences should beggining uppercase.
This rules is going to be disabled.
Esto es un errorr.
esta oración debe comenzar con mayúsculas.
Esta regla sera desactivada.
\end{document}

View File

BIN
nvim/spell/nl.utf-8.spl Normal file

Binary file not shown.

BIN
nvim/spell/nl.utf-8.sug Normal file

Binary file not shown.