diff options
| author | christianchiarulli <[email protected]> | 2021-07-03 23:46:16 -0400 | 
|---|---|---|
| committer | christianchiarulli <[email protected]> | 2021-07-03 23:46:16 -0400 | 
| commit | ddc0c71dae44aaf39742201704c22f9cf92073de (patch) | |
| tree | 2ba85288d1ae1997ac55b70ad36330b3036b75b0 | |
| parent | 8f37e7f2784b56d918f64960fd7b5c02947904f4 (diff) | |
| parent | 632e7bf19418e5792538bbedb602b1e10215fa52 (diff) | |
Merge branch 'master' of github.com:ChristianChiarulli/LunarVim into stable
| -rw-r--r-- | ftplugin/c.lua | 10 | ||||
| -rw-r--r-- | ftplugin/javascript.lua | 2 | ||||
| -rw-r--r-- | ftplugin/javascriptreact.lua | 2 | ||||
| -rw-r--r-- | ftplugin/tex.lua (renamed from ftplugin/latex.lua) | 0 | ||||
| -rw-r--r-- | ftplugin/typescript.lua | 2 | ||||
| -rw-r--r-- | ftplugin/typescriptreact.lua | 2 | ||||
| -rw-r--r-- | lua/default-config.lua | 3 | ||||
| -rw-r--r-- | lua/lsp/efm-general-ls.lua | 58 | ||||
| -rw-r--r-- | lua/lsp/ts-fmt-lint.lua | 66 | ||||
| -rw-r--r-- | lua/lv-dashboard/init.lua | 2 | ||||
| -rw-r--r-- | lua/lv-which-key/init.lua | 3 | ||||
| -rwxr-xr-x | utils/bin/nv | 2 | ||||
| -rwxr-xr-x | utils/installer/install.sh | 6 | ||||
| -rw-r--r-- | utils/installer/lv-config.example.lua | 6 | 
14 files changed, 99 insertions, 65 deletions
| diff --git a/ftplugin/c.lua b/ftplugin/c.lua index 8a7ef9fd..a2324986 100644 --- a/ftplugin/c.lua +++ b/ftplugin/c.lua @@ -19,3 +19,13 @@ require'lspconfig'.clangd.setup {          })      }  } + +if O.lang.clang.autoformat then +    require('lv-utils').define_augroups({ +      _clang_autoformat = { +         {'BufWritePre *.c lua vim.lsp.buf.formatting_sync(nil,1000)'}, +         {'BufWritePre *.h lua vim.lsp.buf.formatting_sync(nil,1000)'}, +         {'BufWritePre *.cpp lua vim.lsp.buf.formatting_sync(nil,1000)'}, +         {'BufWritePre *.hpp lua vim.lsp.buf.formatting_sync(nil,1000)'}, +    }}) +end diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua index 173f6693..16254da3 100644 --- a/ftplugin/javascript.lua +++ b/ftplugin/javascript.lua @@ -36,6 +36,8 @@ require'lspconfig'.tsserver.setup {      }  } +require'lsp.ts-fmt-lint'.setup() +  if O.lang.tsserver.autoformat then      require('lv-utils').define_augroups({          _javascript_autoformat = { diff --git a/ftplugin/javascriptreact.lua b/ftplugin/javascriptreact.lua index 173f6693..16254da3 100644 --- a/ftplugin/javascriptreact.lua +++ b/ftplugin/javascriptreact.lua @@ -36,6 +36,8 @@ require'lspconfig'.tsserver.setup {      }  } +require'lsp.ts-fmt-lint'.setup() +  if O.lang.tsserver.autoformat then      require('lv-utils').define_augroups({          _javascript_autoformat = { diff --git a/ftplugin/latex.lua b/ftplugin/tex.lua index 179c143c..179c143c 100644 --- a/ftplugin/latex.lua +++ b/ftplugin/tex.lua diff --git a/ftplugin/typescript.lua b/ftplugin/typescript.lua index 173f6693..16254da3 100644 --- a/ftplugin/typescript.lua +++ b/ftplugin/typescript.lua @@ -36,6 +36,8 @@ require'lspconfig'.tsserver.setup {      }  } +require'lsp.ts-fmt-lint'.setup() +  if O.lang.tsserver.autoformat then      require('lv-utils').define_augroups({          _javascript_autoformat = { diff --git a/ftplugin/typescriptreact.lua b/ftplugin/typescriptreact.lua index 173f6693..16254da3 100644 --- a/ftplugin/typescriptreact.lua +++ b/ftplugin/typescriptreact.lua @@ -36,6 +36,8 @@ require'lspconfig'.tsserver.setup {      }  } +require'lsp.ts-fmt-lint'.setup() +  if O.lang.tsserver.autoformat then      require('lv-utils').define_augroups({          _javascript_autoformat = { diff --git a/lua/default-config.lua b/lua/default-config.lua index 83ff1cc2..7a26f242 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -150,7 +150,8 @@ O = {                  underline = true,              },              cross_file_rename = true, -            header_insertion = 'never' +            header_insertion = 'never', +            autoformat = false  -- update this to true for enabling autoformat          },          ruby = {              diagnostics = { diff --git a/lua/lsp/efm-general-ls.lua b/lua/lsp/efm-general-ls.lua deleted file mode 100644 index 8b4b8449..00000000 --- a/lua/lsp/efm-general-ls.lua +++ /dev/null @@ -1,58 +0,0 @@ --- Example configuations here: https://github.com/mattn/efm-langserver - --- tsserver/web javascript react, vue, json, html, css, yaml -local prettier = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true} --- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed. --- local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true} - -local eslint = { -    lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}", -    lintIgnoreExitCode = true, -    lintStdin = true, -    lintFormats = {"%f:%l:%c: %m"}, -    formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}", -    formatStdin = true -} - -local tsserver_args = {} - -if O.lang.tsserver.formatter == 'prettier' then table.insert(tsserver_args, prettier) end - -if O.lang.tsserver.linter == 'eslint' then table.insert(tsserver_args, eslint) end - --- local markdownlint = { ---     -- TODO default to global lintrc ---     -- lintcommand = 'markdownlint -s -c ./markdownlintrc', ---     lintCommand = 'markdownlint -s', ---     lintStdin = true, ---     lintFormats = {'%f:%l %m', '%f:%l:%c %m', '%f: %l: %m'} --- } - -local markdownPandocFormat = {formatCommand = 'pandoc -f markdown -t gfm -sp --tab-stop=2', formatStdin = true} - -require"lspconfig".efm.setup { -    -- init_options = {initializationOptions}, -    cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, -    init_options = {documentFormatting = true, codeAction = false}, -    filetypes = {"lua", "python", "javascriptreact", "javascript", "typescript","typescriptreact","sh", "html", "css", "yaml", "markdown", "vue"}, -    settings = { -        rootMarkers = {".git/"}, -        languages = { -            javascript = tsserver_args, -            javascriptreact = tsserver_args, -			typescript = tsserver_args, -			typescriptreact = tsserver_args, -            html = {prettier}, -            css = {prettier}, -            json = {prettier}, -            yaml = {prettier}, -            markdown = {markdownPandocFormat} -            -- javascriptreact = {prettier, eslint}, -            -- javascript = {prettier, eslint}, -            -- markdown = {markdownPandocFormat, markdownlint}, -        } -    } -} - --- Also find way to toggle format on save --- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua new file mode 100644 index 00000000..3ca97d71 --- /dev/null +++ b/lua/lsp/ts-fmt-lint.lua @@ -0,0 +1,66 @@ +-- Example configuations here: https://github.com/mattn/efm-langserver +-- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed. +local M = {} + +M.setup = function() +    local tsserver_args = {} + +    local prettier = { +        formatCommand = "prettier --stdin-filepath ${INPUT}", +        formatStdin = true +    } + +    if vim.fn.glob("node_modules/.bin/prettier") then +        prettier = { +            formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", +            formatStdin = true +        } +    end + +    -- TODO global eslint? + +    local eslint = { +        lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}", +        lintIgnoreExitCode = true, +        lintStdin = true, +        lintFormats = {"%f:%l:%c: %m"}, +        -- formatCommand = "./node_modules/.bin/eslint -f unix --fix --stdin-filename ${INPUT}", -- TODO check if eslint is the formatter then add this +        formatStdin = true +    } + +    if O.lang.tsserver.formatter == 'prettier' then +        table.insert(tsserver_args, prettier) +    end + +    if O.lang.tsserver.linter == 'eslint' then +        table.insert(tsserver_args, eslint) +    end + +    require"lspconfig".efm.setup { +        -- init_options = {initializationOptions}, +        cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, +        init_options = {documentFormatting = true, codeAction = false}, +        filetypes = { +            "javascriptreact", "javascript", "typescript", "typescriptreact", +            "html", "css", "yaml", "vue" +        }, +        settings = { +            rootMarkers = {".git/", "package.json"}, +            languages = { +                javascript = tsserver_args, +                javascriptreact = tsserver_args, +                typescript = tsserver_args, +                typescriptreact = tsserver_args, +                html = {prettier}, +                css = {prettier}, +                json = {prettier}, +                yaml = {prettier} +                -- javascriptreact = {prettier, eslint}, +                -- javascript = {prettier, eslint}, +                -- markdown = {markdownPandocFormat, markdownlint}, +            } +        } +    } +end + +return M diff --git a/lua/lv-dashboard/init.lua b/lua/lv-dashboard/init.lua index e577fdc3..99fcb10f 100644 --- a/lua/lv-dashboard/init.lua +++ b/lua/lv-dashboard/init.lua @@ -30,7 +30,7 @@ M.config = function()          },          f = {              description = {'  Neovim Config Files'}, -            command = 'lua require(\'telescope.builtin\').find_files({search_dirs = {"~/.config/nvim"}})' +            command = 'Telescope find_files cwd=' .. CONFIG_PATH          }          -- e = {description = {'  Marks              '}, command = 'Telescope marks'}      } diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index 3af04edf..88dd2ef0 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -213,7 +213,8 @@ local mappings = {          r = {"<cmd>Lspsaga rename<cr>", "Rename"},          t = {"<cmd>LspTypeDefinition<cr>", "Type Definition"},          x = {"<cmd>cclose<cr>", "Close Quickfix"}, -        s = {"<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols"}, +        s = {O.plugin.symbol_outline.active and "<cmd>SymbolsOutline<cr>" or +            "<cmd> Telescope lsp_document_symbols<cr>", "Document Symbols"},          S = {              "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>",              "Workspace Symbols" diff --git a/utils/bin/nv b/utils/bin/nv index 3408e212..87e5e72a 100755 --- a/utils/bin/nv +++ b/utils/bin/nv @@ -1,2 +1,2 @@  #!/bin/bash -nvim -u ~/.config/nvcode/init.lua +nvim -u ~/.config/nvim/init.lua diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 4bd640a6..395cec38 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -192,16 +192,16 @@ else  fi  if [ -e "$HOME/.config/nvim/init.lua" ]; then -	echo 'nvcode already installed' +	echo 'LunarVim already installed'  else  	# clone config down  	cloneconfig  	# echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc -	# echo 'export PATH=$HOME/.config/nvcode/utils/bin:$PATH' >>~/.bashrc +	# echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc  fi  echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"  # echo "I also recommend you add 'set preview_images_method ueberzug' to ~/.config/ranger/rc.conf" -# echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH appending to zshrc/bashrc' +# echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc' diff --git a/utils/installer/lv-config.example.lua b/utils/installer/lv-config.example.lua index c90d4876..f71ad561 100644 --- a/utils/installer/lv-config.example.lua +++ b/utils/installer/lv-config.example.lua @@ -83,6 +83,12 @@ O.lang.go.autoformat = true  -- rust  O.lang.rust.autoformat = true + +-- clang +O.lang.clang.autoformat = false -- Set to true to enable auto-format in C/C++ files. + + +  -- create custom autocommand field (This would be easy with lua)  -- Turn off relative_numbers | 
