Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: minimal basic ide #17

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d8605c9
feat: start with basic lvim options and builtin configs
0x736d Oct 4, 2022
89b660c
feat: auto install treesitter parsers & some lsp servers
0x736d Oct 4, 2022
897f444
fix: disable virtual_text for diagnostics
0x736d Oct 4, 2022
8cbd476
feat(plugin): add additional colorscheme plugins
0x736d Oct 4, 2022
be6abb9
feat: add manual configurations for language servers
0x736d Oct 4, 2022
53b5b1e
feat: setup formatting and linting for common langs
0x736d Oct 4, 2022
16ba032
feat: setup codeactions using null-ls
0x736d Oct 4, 2022
9ee21db
feat(plugin): add some utility plugins
0x736d Oct 4, 2022
76c6b58
feat(plugin): add refactoring.nvim
0x736d Oct 4, 2022
05f2779
feat(plugin): add nvim-spectre & trouble.nvim with default setup options
0x736d Oct 4, 2022
3b706fe
feat(keybinds): add additional which-key mappings
0x736d Oct 4, 2022
24001e0
fix: enable autotag
0x736d Oct 4, 2022
988b2d1
chore: add .stylua.toml
0x736d Oct 4, 2022
cf691a4
chore: update .gitignore
0x736d Oct 4, 2022
619a29d
fix: remove keymap for loclist & use correct provider for type defini…
0x736d Oct 4, 2022
bf7173e
chore: update readme
0x736d Oct 4, 2022
12b0669
chore: move submission guidelines to `guidelines.md`
0x736d Oct 4, 2022
d2ac91b
chore: update readme
0x736d Oct 4, 2022
fbe163f
fix: use `vim.deepcopy` before modifying client capabilities
0x736d Oct 4, 2022
9ca5c5f
fix: add missing callbacks and options to `gopls` setup
0x736d Oct 4, 2022
157fec7
fix: remove `ensure_installed` table
0x736d Oct 6, 2022
ee4579a
fix: remove unnecessary lunarvim opts
0x736d Oct 6, 2022
2162810
fix: remove colorscheme plugins
0x736d Oct 6, 2022
e0af1bd
fix: update plugin table
0x736d Oct 6, 2022
26b31c0
fix: remove `rustfmt` from null-ls formatting sources
0x736d Oct 6, 2022
118deaa
Add .stylua.toml from Lunarvim/lunarvim (#38)
dapc11 Oct 17, 2022
d71e226
fix: pass `lvim` to `--globals` for `luacheck`
0x736d Oct 27, 2022
10b34f2
chore: rename `guidelines.md` to `CONTRIBUTING.md`
0x736d Dec 6, 2022
363f883
chore: update README.md
0x736d Dec 6, 2022
0789072
fix: update config.lua
0x736d Dec 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ luac.out
*.x86_64
*.hex


plugin
6 changes: 6 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
no_call_parentheses = true
73 changes: 70 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,75 @@

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this file into .github/README.md

A great starting point for your LunarVim journey!
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved

<details open>
<summary>
<strong>Contents</strong>
</summary>

- [Submission Guidelines](#submission-guidelines)
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
- [Supported languages](#supported-languages)
- [Requirements](#requirements)
- [Keybinds](#additional-keybinds)
</details>

## Submission Guidelines

LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
- Ideally one file!
- IDE config must be added to its own branch named `lang-ide`
- try to keep it focused on the language and not your biased keybindings/options
See [guidelines](guidelines.md)

LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
## Supported languages
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Supported languages
## Available configurations


> **Note**
> formatting, diagnostics, completions should work out of the box for the languages
> below with the `LunarVim` configuration in this branch

- C/C++
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably link to the branch

- Typescript/Javascript
- python
- go
- rust
- bash
- html
- css
- json
- yaml
- toml
- dockerfile

## Requirements

Most of the language servers installation should happen automatically, but there
is a few that are manually configured and may requires manual installation.

Install them with the command below

```
:MasonInstall clangd rust_analyzer gopls
```

Binaries needed for diagnostics and formatting requires manual installation.
You need to install them using the builtin `mason.nvim` or with your favorite package
manager.

use the command below to install them with mason

```
:MasonInstall eslint_d prettier yamllint taplo goimports golangci-lint shellcheck shfmt hadolint flake8 black
```

### Additional keybinds

> **Note**
> Leader is mapped to <kbd>Space</kbd>

| Mode | Key | Action |
| ------ | ------------------------------------------ | --------------------------------------------- |
| visual | <kbd>Space</kbd>+<kbd>r</kbd>+<kbd>r</kbd> | Refactor selection |
| normal | <kbd>Space</kbd>+<kbd>P</kbd> | Project menu |
| normal | <kbd>Space</kbd>+<kbd>r</kbd>+<kbd>o</kbd> | Search and replace (open spectre panel) |
| normal | <kbd>Space</kbd>+<kbd>r</kbd>+<kbd>f</kbd> | Search and replace (search current file) |
| normal | <kbd>Space</kbd>+<kbd>r</kbd>+<kbd>c</kbd> | Search and replace (search word under cursor) |
| normal | <kbd>Space</kbd>+<kbd>t</kbd>+<kbd>w</kbc> | Workspace diagnostics |
| normal | <kbd>Space</kbd>+<kbd>t</kbd>+<kbd>d</kbc> | Document diagnostics |
| normal | <kbd>Space</kbd>+<kbd>t</kbd>+<kbd>t</kbc> | LSP Type definitions |
| normal | <kbd>Space</kbd>+<kbd>t</kbd>+<kbd>r</kbc> | LSP references |
| normal | <kbd>Space</kbd>+<kbd>t</kbd>+<kbd>q</kbc> | Quickfix |
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
264 changes: 264 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
lvim.format_on_save = true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this file as it overlaps with purpose with the branches and config.example.lua, it would also be yet another piece of documentation that require maintenance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylo252 So no config.lua in master branch and have links in README.md for branches with their respective lang/ide configuration... 😕 ( I think the original idea was to have examples configuration for few common languages and plugins etc.. )

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I'm talking about linking to this file instead: https://github.com/LunarVim/LunarVim/blob/d3ade21d85084634517848a7fd3582bbf2d6c278/utils/installer/config.example.lua

We should ideally have a single "common" example config.lua, that's always kept up to date with any changes/recommendations. We can always update that file, if you have any concrete ideas, see LunarVim/LunarVim#3519.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response... I've added all the changes to #56 since after removing config.lua from this PR it wouldn't be addressing #1 anymore.


lvim.builtin.treesitter.highlight.enable = true
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
lvim.builtin.treesitter.autotag.enable = true

------------------------------------------------------------------------
-- auto install treesitter parsers
------------------------------------------------------------------------
lvim.builtin.treesitter.ensure_installed = {
"c",
"cpp",
"javascript",
"typescript",
"tsx",
"json",
"lua",
"html",
"python",
"css",
"scss",
"yaml",
"toml",
"go",
"bash",
"dockerfile",
"rust",
}

------------------------------------------------------------------------
-- LSP settings
------------------------------------------------------------------------
lvim.lsp.diagnostics.virtual_text = false

-- language servers added to the skipped_servers table will not be -
-- automatically configured by LunarVim

-- Add servers to the skipped_servers table when manual configuration
-- of a language server is needed
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "gopls", "rust_analyzer", "clangd" })

-- See below the examples of manual configuration of `gopls`, `clangd` -
-- and `rust_analyzer`
------------------------------------------------------------------------
-- Manual setup of language servers
------------------------------------------------------------------------

local lsp_manager = require "lvim.lsp.manager"
local on_init = require("lvim.lsp").common_on_init
local on_attach = require("lvim.lsp").common_on_attach
local capabilities = require("lvim.lsp").common_capabilities()
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved

-- clangd
local clangd_flags = {
"--offset-encoding=utf-16",
"--fallback-style=google",
"--enable-config",
"--clang-tidy",
}

local clangd_capabilities = vim.deepcopy(capabilities)
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
clangd_capabilities.offsetEncoding = { "utf-16" }

-- clangd
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
lsp_manager.setup("clangd", {
cmd = { "clangd", unpack(clangd_flags) },
on_init = on_init,
on_attach = on_attach,
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
capabilities = clangd_capabilities,
})

-- rust_analyzer
lsp_manager.setup("rust_analyzer", {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
settings = {
["rust-analyzer"] = {
checkOnSave = {
enable = true,
command = "clippy",
},
},
},
})

-- gopls
lsp_manager.setup("gopls", {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved
settings = {
gopls = {
gofumpt = true,
codelenses = {
gc_details = true,
generate = true,
test = true,
tidy = true,
upgrade_dependency = true,
},
usePlaceholders = true,
analyses = {
fieldalignment = true,
nilness = true,
shadow = true,
unusedparams = true,
unusedwrite = true,
},
staticcheck = true,
},
},
})

------------------------------------------------------------------------
-- formatters
------------------------------------------------------------------------
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
{
command = "prettier",
filetypes = {
"json",
"jsonc",
"yaml",
"markdown",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"css",
"scss",
"html",
},
},
{ command = "stylua", filetypes = { "lua" } },
{ command = "goimports", filetypes = { "go", "gomod" } },
{ command = "shfmt", filetypes = { "sh" } },
{ command = "black", filetypes = { "python" } },
}

------------------------------------------------------------------------
-- linters
------------------------------------------------------------------------
local linters = require "lvim.lsp.null-ls.linters"
linters.setup {
{ command = "flake8", filetypes = { "python" } },
{ command = "golangci_lint", filetypes = { "go" } },
{ command = "hadolint", filetypes = { "dockerfile" } },
{ command = "shellcheck", filetypes = { "sh" } },
{
command = "luacheck",
filetypes = { "lua" },
args = {
"--globals",
"vim",
"lvim",
"--formatter",
"plain",
"--codes",
"--ranges",
"--filename",
"$FILENAME",
"-",
},
},

{ command = "yamllint", filetypes = { "yaml" } },
{ command = "eslint_d", filetyps = { "javascript", "javascriptreact", "typescript", "typescriptreact" } },
}

------------------------------------------------------------------------
-- codeactions
------------------------------------------------------------------------
local codeactions = require "lvim.lsp.null-ls.code_actions"
codeactions.setup {
{ name = "gitsigns" },
{ name = "refactoring" },
{ command = "eslint_d", filetype = { "javascript", "javascriptreact", "typescript", "typescriptreact" } },
}

------------------------------------------------------------------------
-- Plugins
------------------------------------------------------------------------
lvim.plugins = {

-- utility plugins
{ "tpope/vim-surround", keys = { "c", "d", "y" } },

-- search and replace
"windwp/nvim-spectre",

-- diagnostics with trouble.nvim
"folke/trouble.nvim",

-- auto close html tags
"windwp/nvim-ts-autotag",

{
-- better UX with vim.ui.select and vim.ui.input
"stevearc/dressing.nvim",
config = function()
require("dressing").setup {
input = {
prefer_width = 55,
prompt_align = "center",
min_width = 30,
relative = "editor",
},
select = {
backend = { "telescope" },
telescope = require("telescope.themes").get_dropdown { hide_preview = false },
},
}
end,
},

{
-- required for refactoring codeactions (caveat: only works with few common languages)
-- view supported languages at https://github.com/ThePrimeagen/refactoring.nvim#supported-languages
"ThePrimeagen/refactoring.nvim",
config = function()
require("refactoring").setup {
-- prompt for return type
prompt_func_return_type = {
go = true,
cpp = true,
c = true,
java = true,
},
-- prompt for function parameters
prompt_func_param_type = {
go = true,
cpp = true,
c = true,
java = true,
},
}
end,
},
}

------------------------------------------------------------------------
-- custom which-key mappings
------------------------------------------------------------------------
lvim.builtin.which_key.vmappings["r"] = {
name = "+refactor",
r = { "<Esc><cmd>lua require('telescope').extensions.refactoring.refactors()<CR>", "refactor selection" },
}

lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" }
lvim.builtin.which_key.mappings["r"] = {
name = "+Search and Replace",
o = { "<cmd>lua require('spectre').open()<cr>", "open" },
f = { "<cmd>lua require('spectre').open_file_search()<cr>", "file search" },
c = { "<cmd>lua require('spectre').open_visual({select_word=true})<cr>", "search word under cursor" },
}
lvim.builtin.which_key.mappings["t"] = {
name = "+Trouble",
w = { "<cmd>Trouble workspace_diagnostics<cr>", "Workspace Diagnostics" },
d = { "<cmd>Trouble document_diagnostics<cr>", "Document Diagnostics" },
q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
r = { "<cmd>Trouble lsp_references<cr>", "LSP References" },
t = { "<cmd>Trouble lsp_type_definitions<cr>", "LSP Type definitions" },
}
5 changes: 5 additions & 0 deletions guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Submission Guidelines

- Ideally one file!
- IDE config must be added to its own branch named `lang-ide`
- try to keep it focused on the language and not your biased keybindings/options
LostNeophyte marked this conversation as resolved.
Show resolved Hide resolved