diff --git a/CHANGELOG.md b/CHANGELOG.md index f1aef728..e2a202a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -## [2.1.0] - 2019-xx-xx +## [2.1.1] - 2019-xx-xx + +### Changed + +- Improve syntax highlight (#128, #127) +- Improve Paths to linter (#124) +- Improve environment processing (#126) + +### Added + +- New snippets (#104) + +## [2.1.0] - 2019-03-26 ### Changed diff --git a/language-configuration.json b/language-configuration.json index 87572f0b..4027e926 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -55,7 +55,7 @@ "flags": "i" }, "decreaseIndentPattern": { - "pattern": "^\\s*end\\s*(select|if|do|function|subroutine|module|program)\\b.*$|^\\s*else|case\\b.*$", + "pattern": "^\\s*end\\s*(select|if|do|function|subroutine|module|program)\\b.*$|^\\s*(else|case)\\b.*$", "flags": "i" } } diff --git a/package.json b/package.json index 395b8cd6..19bea2df 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "linter-gfortran", "displayName": "Modern Fortran", "description": "Modern Fortran language support, including syntax highlighting and error detection.", - "version": "2.1.0", + "version": "2.1.1", "publisher": "krvajalm", "engines": { "vscode": "^1.30.x" diff --git a/snippets/fortran90.json b/snippets/fortran90.json index bfb8ec1e..db986fee 100644 --- a/snippets/fortran90.json +++ b/snippets/fortran90.json @@ -3,8 +3,8 @@ "prefix": "program", "body": [ "program ${1:name}", - "implicit none", - "", + "\timplicit none", + "\t${0}", "end program ${1:name}" ], "description": "Program Skeleton" @@ -13,9 +13,10 @@ "prefix": "module", "body": [ "module ${1:name}", - "implicit none", - "${2}", + "\timplicit none", + "\t${2}", "contains", + "\t${0}", "end module ${1:name}" ], "description": "Create a new module" @@ -23,10 +24,9 @@ "Do Loop": { "prefix": "do", "body": [ - "do ${1:index} = ${2:start},${3:end}", - " !TODO_statement", - " ${4}", - "enddo" + "do ${1:index} = ${2:start}, ${3:end}", + "\t${0}", + "end do" ], "description": "Create a do loop" }, @@ -34,10 +34,10 @@ "prefix": "fun", "body": [ "function ${1:func}(${2:arg}) result(${3:retval})", - "${4:type} :: ${2:arg}", - "${4:type} :: ${3:retval}", - " !TODO_add_body", - " ${5}", + "\timplicit none", + "\t${4:type} :: ${2:arg}", + "\t${4:type} :: ${3:retval}", + "\t${0}", "end function ${1:func}" ], "description": "Create a function" @@ -46,35 +46,66 @@ "prefix": "sub", "body": [ "subroutine ${1:routine}(${2:arg1}, ${3: arg2})", - "${4:type1},intent(in) :: ${2:arg1}", + "implicit none", + "${4:type1},intent(in) :: ${2:arg1}", "${5:type2},intent(out) :: ${3:arg2}", - " !TODO_add_body", - " ${6}", + "${0}", "end subroutine ${1:routine}" ], - "description": "Create a function" + "description": "Create a subroutine" + }, + "ifs": { + "prefix": "if", + "body": [ + "if ( ${1:condition} ) ${0}" + ], + "description": "if (single line)" + }, + "if": { + "prefix": "if", + "body": [ + "if ( ${1:condition} ) then", + "\t${0}", + "end if" + ], + "description": "if then" + }, + "elif": { + "prefix": "el", + "body": [ + "else if ( ${1:condition} ) then", + "\t${0}" + ], + "description": "else if" + }, + "imp": { + "prefix": "imp", + "body": [ + "implicit none", + "${0}" + ], + "description": "implicit none" }, "Module documentation header": { - "prefix": "modoc" , - "body": [ "!------------------------------------------------------------------------------", - "! ${1:Institution}, ${2:Affiliation}", - "!------------------------------------------------------------------------------", - "!", - "! MODULE: ${3: Module name}", - "!", - "!> @author", - "!> ${4:Author Name}}", - "!", - "! DESCRIPTION: ", - "!> ${5: Short module description}", - "!", - "! REVISION HISTORY:", - "! dd Mmm yyyy - Initial Version", - "! TODO_dd_mmm_yyyy - TODO_describe_appropriate_changes - TODO_name", - "!------------------------------------------------------------------------------" + "prefix": "modoc", + "body": [ + "!------------------------------------------------------------------------------", + "! ${1:Institution}, ${2:Affiliation}", + "!------------------------------------------------------------------------------", + "!", + "! MODULE: ${3: Module name}", + "!", + "!> @author", + "!> ${4:Author Name}}", + "!", + "! DESCRIPTION: ", + "!> ${5: Short module description}", + "!", + "! REVISION HISTORY:", + "! dd Mmm yyyy - Initial Version", + "! TODO_dd_mmm_yyyy - TODO_describe_appropriate_changes - TODO_name", + "!------------------------------------------------------------------------------" ], "description": "Add module documentation header" } - - } \ No newline at end of file diff --git a/src/features/linter-provider.ts b/src/features/linter-provider.ts index 9bef7c08..479b5291 100644 --- a/src/features/linter-provider.ts +++ b/src/features/linter-provider.ts @@ -33,11 +33,9 @@ export default class FortranLintingProvider { * * see also: https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html */ - const env = { - ...process.env, - LC_ALL: 'C' - }; - if (process.platform == 'win32') { + const env = process.env; + env.LC_ALL = 'C'; + if (process.platform === 'win32') { // Windows needs to know the path of other tools if (!env.Path.includes(path.dirname(command))) { env.Path = `${path.dirname(command)}${path.delimiter}${env.Path}`; @@ -107,7 +105,7 @@ export default class FortranLintingProvider { ); let argList = [ ...args, - getIncludeParams(includePaths), // include paths + ...getIncludeParams(includePaths), // include paths textDocument.fileName, `-o ${fileNameWithoutExtension}.mod` ]; diff --git a/src/lib/helper.ts b/src/lib/helper.ts index 978cd8b0..dd3b7b12 100644 --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -87,10 +87,7 @@ export const _loadDocString = (keyword: string) => { }; export const getIncludeParams = (paths: string[]) => { - if (paths.length === 0) { - return ''; - } - return '-I ' + paths.join(' '); + return paths.map(path => `-I${path}`) }; export function isPositionInString( diff --git a/syntaxes/fortran_free-form.tmLanguage.json b/syntaxes/fortran_free-form.tmLanguage.json index 7c04f80e..4f6cb6b1 100644 --- a/syntaxes/fortran_free-form.tmLanguage.json +++ b/syntaxes/fortran_free-form.tmLanguage.json @@ -1236,7 +1236,7 @@ "patterns": [ { "comment": "rest of else line", - "begin": "(?!(\\s*!)|(\\s*\\n))", + "begin": "(?!(\\s*(;|!|\\n)))", "end": "(?=[;!\\n])", "patterns": [ { @@ -1278,7 +1278,7 @@ "patterns": [ { "name": "meta.block.select.fortran", - "begin": "(?i)\\b(select\\s*case|selectcase)\\b", + "begin": "(?i)\\b(select)", "beginCaptures": { "1": { "name": "keyword.control.select.fortran" @@ -1293,7 +1293,7 @@ "patterns": [ { "comment": "Select case construct. Introduced in the Fortran 1990 standard.", - "begin": "(?i)^\\s*\\b(case)\\b", + "begin": "(?i)\\s*(case)\\b", "beginCaptures": { "1": { "name": "keyword.control.case.fortran" @@ -1336,10 +1336,10 @@ }, { "comment": "Select type construct. Introduced in the Fortran 2003 standard.", - "begin": "(?i)\\G\\s*\\b(type)\\b", + "begin": "(?i)\\s*(type)\\b", "beginCaptures": { "1": { - "name": "keyword.control.case.fortran" + "name": "keyword.control.type.fortran" } }, "end": "(?i)(?=\\b(end\\s*select)\\b)", @@ -1348,7 +1348,7 @@ "include": "#parentheses" }, { - "begin": "(?i)\\b(?:(class)|(type))\\b", + "begin": "(?i)\\b(?:(class)|(type))", "beginCaptures": { "1": { "name": "keyword.control.class.fortran" @@ -1368,7 +1368,7 @@ } }, { - "match": "(?i)\\G\\s*\\b(is)\\b", + "match": "(?i)\\G\\s*(is)\\b", "captures": { "1": { "name": "keyword.control.is.fortran" @@ -4064,7 +4064,7 @@ }, "type-specification-statements": { "name": "meta.specification.type.fortran", - "begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type)\\b(?![^'\";!\\n]*\\bfunction\\b))", + "begin": "(?ix)(?=\\b(?:character|class|complex|double\\s*precision|double\\s*complex|integer|logical|real|type|dimension)\\b(?![^'\";!\\n]*\\bfunction\\b))", "end": "(?=[\\);!\\n])", "patterns": [ { @@ -4670,7 +4670,7 @@ ] }, { - "match": "(?ix)\\b(?:(complex)|(double\\s*precision)|(double\\s*complex)|(integer)|(real))\\b(?:\\s*(\\*)\\s*(\\d*))?", + "match": "(?ix)\\b(?:(complex)|(double\\s*precision)|(double\\s*complex)|(integer)|(real)|(dimension))\\b(?:\\s*(\\*)\\s*(\\d*))?", "captures": { "1": { "name": "storage.type.complex.fortran" @@ -4688,9 +4688,12 @@ "name": "storage.type.real.fortran" }, "6": { + "name": "storage.type.dimension.fortran" + }, + "7": { "name": "keyword.operator.multiplication.fortran" }, - "7": { + "8": { "name": "constant.numeric.fortran" } } diff --git a/syntaxes/openmp_lang.json b/syntaxes/openmp_lang.json index cabe5fbd..c778cae5 100644 --- a/syntaxes/openmp_lang.json +++ b/syntaxes/openmp_lang.json @@ -8,7 +8,7 @@ "name": "meta.openmp.directive", "begin": "(?i)\\G(\\$(omp\\b)?&?)", "beginCaptures": { "1": { "name": "comment.directive.openmp" } }, - "end": "(?=[$\\n])", + "end": "(?=[\\n])", "patterns": [ { "include": "#environment-variables" }, { "include": "#intrinsic-functions" },