From fc663940ff92b2c8c13b828bd479b855a57c27be Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Tue, 9 Jan 2024 13:32:30 -0800 Subject: [PATCH] [nvim] filetype-lua update and nvim.lua cleanup --- .vim/filetype.vim | 1 + .vim/nvim.lua | 147 ++++++++++++++++++++++++------------------------------ 2 files changed, 66 insertions(+), 82 deletions(-) diff --git a/.vim/filetype.vim b/.vim/filetype.vim index 20dba9f..48fb035 100644 --- a/.vim/filetype.vim +++ b/.vim/filetype.vim @@ -124,6 +124,7 @@ autocmd FileType proto let b:auto_trim_whitespace=1 autocmd FileType hy let b:auto_trim_whitespace=1 autocmd FileType idris let b:auto_trim_whitespace=1 autocmd FileType java let b:auto_trim_whitespace=1 +autocmd FileType lua let b:auto_trim_whitespace=1 augroup templates autocmd BufNewFile *.vue 0r ~/.vim/skeletons/vue.skel diff --git a/.vim/nvim.lua b/.vim/nvim.lua index e6837a2..5c69511 100644 --- a/.vim/nvim.lua +++ b/.vim/nvim.lua @@ -73,77 +73,77 @@ nvim_lsp.gopls.setup({ }) local function filter(arr, func) - -- Filter in place - -- https://stackoverflow.com/questions/49709998/how-to-filter-a-lua-array-inplace - local new_index = 1 - local size_orig = #arr - for old_index, v in ipairs(arr) do - if func(v, old_index) then - arr[new_index] = v - new_index = new_index + 1 - end + -- Filter in place + -- https://stackoverflow.com/questions/49709998/how-to-filter-a-lua-array-inplace + local new_index = 1 + local size_orig = #arr + for old_index, v in ipairs(arr) do + if func(v, old_index) then + arr[new_index] = v + new_index = new_index + 1 end - for i = new_index, size_orig do arr[i] = nil end + end + for i = new_index, size_orig do arr[i] = nil end end local function pyright_accessed_filter(diagnostic) - -- Allow kwargs to be unused, sometimes you want many functions to take the - -- same arguments but you don't use all the arguments in all the functions, - -- so kwargs is used to suck up all the extras - if diagnostic.message == '"kwargs" is not accessed' then - return false - end - -- Allow variables starting with an underscore - if string.match(diagnostic.message, '"_.+" is not accessed') then - return false - end + -- Allow kwargs to be unused, sometimes you want many functions to take the + -- same arguments but you don't use all the arguments in all the functions, + -- so kwargs is used to suck up all the extras + if diagnostic.message == '"kwargs" is not accessed' then + return false + end + -- Allow variables starting with an underscore + if string.match(diagnostic.message, '"_.+" is not accessed') then + return false + end - return true + return true end local function pyright_custom_diagnostic(a, params, client_id, c, config) - filter(params.diagnostics, pyright_accessed_filter) - vim.lsp.diagnostic.on_publish_diagnostics(a, params, client_id, c, config) + filter(params.diagnostics, pyright_accessed_filter) + vim.lsp.diagnostic.on_publish_diagnostics(a, params, client_id, c, config) end nvim_lsp.pyright.setup({ on_attach = function(client, bufnr) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(pyright_custom_diagnostic, diagnostic_options) -end}) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(pyright_custom_diagnostic, diagnostic_options) +end }) --nvim_lsp.pyright.setup({ on_attach = on_attach }) ---nvim_lsp.pylsp.setup({ - --on_attach = on_attach, - --settings = { - --pylsp = { - --plugins = { - ---- formatter options - ----black = { enabled = true }, - --autopep8 = { enabled = false }, - --yapf = { enabled = false }, - ---- linter options - --pylint = { enabled = false, executable = "pylint" }, - --pyflakes = { enabled = false }, - --pycodestyle = { enabled = false }, - ---- type checker - --pylsp_mypy = { enabled = true }, - ---- auto-completion options - --jedi_completion = { enabled = false }, - ---- import sorting - ----pyls_isort = { enabled = true }, - ----flake8 = { - ----maxLineLength = 100, - ----}, - --pycodestyle = { - --maxLineLength = 100, - --}, - ----rope_autoimport = { - ----enabled = true - ----}, - ----rope_completion = { - ----enabled = true - ----}, - --} - --} - --} +--nvim_lsp.pylsp.setup({ +--on_attach = on_attach, +--settings = { +--pylsp = { +--plugins = { +---- formatter options +----black = { enabled = true }, +--autopep8 = { enabled = false }, +--yapf = { enabled = false }, +---- linter options +--pylint = { enabled = false, executable = "pylint" }, +--pyflakes = { enabled = false }, +--pycodestyle = { enabled = false }, +---- type checker +--pylsp_mypy = { enabled = true }, +---- auto-completion options +--jedi_completion = { enabled = false }, +---- import sorting +----pyls_isort = { enabled = true }, +----flake8 = { +----maxLineLength = 100, +----}, +--pycodestyle = { +--maxLineLength = 100, +--}, +----rope_autoimport = { +----enabled = true +----}, +----rope_completion = { +----enabled = true +----}, +--} +--} +--} --}) --nvim_lsp.clangd.setup({ on_attach = on_attach }) @@ -249,8 +249,9 @@ require('lspconfig').efm.setup(vim.tbl_extend('force', efmls_config, { -- Enable diagnostics vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, - diagnostic_options) + vim.lsp.diagnostic.on_publish_diagnostics, + diagnostic_options +) -- Compe setup require 'compe'.setup { @@ -283,7 +284,7 @@ require 'compe'.setup { --require'lsp_signature'.on_attach(signature_cfg) -saga_cfg = { +local saga_cfg = { code_action_prompt = { enable = false, sign = false, @@ -317,6 +318,7 @@ _G.tab_complete = function() return vim.fn['compe#complete']() end end + _G.s_tab_complete = function() if vim.fn.pumvisible() == 1 then return t "" @@ -482,25 +484,6 @@ require('telescope').setup { } -local dropdown = require 'telescope.themes'.get_dropdown({ - --previewer = false, - --prompt_title = "", - --results_height = 16, - --width = 0.6, - --borderchars = { - --{"─", "│", "─", "│", "╭", "╮", "╯", "╰"}, - --prompt = {"─", "│", " ", "│", "╭", "╮", "│", "│"}, - --results = {"─", "│", "─", "│", "├", "┤", "╯", "╰"}, - --preview = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"} - --}, - --winblend = 10 -}) - -local telescope_ivy = require 'telescope.themes'.get_ivy({ - -}) - - -- -- Treesitter -- @@ -607,7 +590,7 @@ function string.insert(str1, str2, pos) end function string.split(s, delimiter) - result = {}; + local result = {}; for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do table.insert(result, match); end